Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Uncaught --> Smarty Compiler: Syntax error in template

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
thiebo
Smarty Pro


Joined: 16 Jan 2005
Posts: 144
Location: Paris

PostPosted: Sun May 03, 2015 8:43 pm    Post subject: Uncaught --> Smarty Compiler: Syntax error in template Reply with quote

Hi,

I've been running an application for quite a few years using smarty. No problems. And wanted to update it all to smarty3 and use pdo instread of mysql. Anyway.

I'm using this setup :

Code:
require ('Smartylibs/Smarty.class.php');
require('env.php'); // contains the path to the the document root

class Smarty_smartysite extends Smarty{
   function __construct()
   {
      parent::__construct();      
      define ('TEMPLATES', CHEMIN.'smarty/templates/');
      
      $this->setTemplateDir(array (TEMPLATES, TEMPLATES.'actes', TEMPLATES.'biblio', TEMPLATES.'voca', TEMPLATES.'util', TEMPLATES.'liens', TEMPLATES.'propos', TEMPLATES.'contact', TEMPLATES.'docus'));
      $this->setCompileDir('smarty/templates_c/');
      $this->setConfigDir('smarty/configs/');
      $this->setCacheDir('smarty/cache/');
      $this->setPluginsDir('Smartylibs/plugins/');

      $this->caching = false;
//      $this->debugging = true;
      $this->assign ('smartysite','smartysite');
}
}



running the debugging went well :


Quote:
Smarty Installation test...
Testing template directory...
/Library/WebServer/Documents/messources/smarty/templates is OK.
/Library/WebServer/Documents/messources/smarty/templates/actes is OK.
/Library/WebServer/Documents/messources/smarty/templates/biblio is OK.
/Library/WebServer/Documents/messources/smarty/templates/voca is OK.
/Library/WebServer/Documents/messources/smarty/templates/util is OK.
/Library/WebServer/Documents/messources/smarty/templates/liens is OK.
/Library/WebServer/Documents/messources/smarty/templates/propos is OK.
/Library/WebServer/Documents/messources/smarty/templates/contact is OK.
/Library/WebServer/Documents/messources/smarty/templates/docus is OK.
Testing compile directory...
/Library/WebServer/Documents/messources/smarty/templates_c is OK.
Testing plugins directory...
/Library/WebServer/Documents/messources/Smartylibs/plugins is OK.
Testing cache directory...
/Library/WebServer/Documents/messources/smarty/cache is OK.
Testing configs directory...
/Library/WebServer/Documents/messources/smarty/configs is OK.
Testing sysplugin files...
... OK
Testing plugin files...
... OK
Tests complete.



In a sub-directory I have this piece of Code :



Code:
require ('../actions.class.php');
   require ('../setup.php');
   $smarty = new Smarty_smartysite;
$actions = new Actions (PDO_DSN, PDO_USER, PDO_PASSWORD);

$contrats = $actions->trouvecontrats();
$smarty->assign ('contrats',$contrats);

$localites = $actions->trouvelocalites();
$smarty->assign ('localites',$localites);

$smarty->assign ('titre','chercher un acte');

$smarty->display ('formchercheacte.tpl');



Of course, I have tested those arrays and they come out fine with {section}

The template contains :

Code:


{include file="entete.tpl"}
{if $smarty.session.dtsmodif == 1}
{include file="menu.tpl"}
{else}
{include file="menuSsDroits.tpl"}
{/if}

<div id="corpus">
   <div id="ttre">
   <h2 class="titre">{$titre}</h2>
   </div>

   <div id="txuni">

   <form action="listeactes.php" method="get">
<div id="vo">Année entre :</div>
            <div id="vb"><input type="text" size="4" name="anmin" value="{$smarty.session.anmin|default:'950'}"></div> <div id="bo">et l'an</div>
            <div id="bob"><input type="text" size="4" name="anmax" value="{$smarty.session.anmax|default:'1350'}"></div>
         </li>


         <li>
            <div id="vb">qualité</div>
            <div id="bo"><select id="select_style" name="auteur"><option label=""></option>{section name=i loop=$auteur}{html_options values=$auteur[i].Auteur selected=$smarty.session.auteur output=$auteur[i].Auteur}{/section}</select></div>
            
         </li>




And as a result I get this :

Quote:
Fatal error: Uncaught --> Smarty Compiler: Syntax error in template "/Library/WebServer/Documents/messources/smarty/templates/actes/formchercheacte.tpl" on line 53 "<div id="vb"><input type="text" size="4" name="anmin" value="{$smarty.session.anmin|default:'950'}"></div> <div id="bo">et l'an</div>" unknown modifier "default" <-- thrown in /Library/WebServer/Documents/messources/Smartylibs/sysplugins/smarty_internal_templatecompilerbase.php on line 53


I can't get my head around it....
Back to top
View user's profile Send private message Visit poster's website
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sun May 03, 2015 10:35 pm    Post subject: Reply with quote

Did you read the error text?
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Sun May 03, 2015 11:50 pm    Post subject: Reply with quote

You set your plugins_dir to 'Smartylibs/plugins/'.

It looks like that you did not update this folder with the plugins from the Smarty 3.1 distribution
Back to top
View user's profile Send private message
thiebo
Smarty Pro


Joined: 16 Jan 2005
Posts: 144
Location: Paris

PostPosted: Mon May 04, 2015 5:51 am    Post subject: Reply with quote

Thanks !!!

running the debugging from the sub-repertory showed what went wrong....
not using absolute paths in setup.php :

Code:
$this->setCompileDir('smarty/templates_c/');
      $this->setConfigDir('smarty/configs/');
      $this->setCacheDir('smarty/cache/');
      $this->setPluginsDir('Smartylibs/plugins/');


Although on the templates I did use absolute paths :

Code:
define ('TEMPLATES', CHEMIN.'smarty/templates/');
     
      $this->setTemplateDir(array (TEMPLATES, TEMPLATES.'actes', TEMPLATES.'biblio', TEMPLATES.'voca', TEMPLATES.'util', TEMPLATES.'liens', TEMPLATES.'propos', TEMPLATES.'contact', TEMPLATES.'docus'));


(CHEMIN is document_root).

crazy...

Thanks for the replies !
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP