Lots of Smarty Error posts...but no solution???

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
knert

Lots of Smarty Error posts...but no solution???

Post by knert »

hi there,

I installed in a template a piece of code for securing some pages. But now I get a Smarty Error.

string(322) "Smarty error: [in template:19 line 23]: syntax error: unrecognized tag: //this should the the absolute path to the no_access.html file - see above include ('/usr/local/psa/home/vhosts/xxxxxxxxxxx/httpdocs/login/no_access.html'); exit; (Smarty_Compiler.class.php, line 439)" string(111) "Smarty error: [in template:19 line 23]: syntax error: unrecognized tag '' (Smarty_Compiler.class.php, line 583)"

When I refresh the page the error is gone, so it has to be a cookie problem.

So, knowing that this forum is very large, I supposed to find an answer for this problem.

But I saw LOTS of Smarty errors but NO solutions at all. Is this Smarty thing such a big pain in the butt?

Please HELP, because otherwise this CMS is useless for me.  :-\
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Lots of Smarty Error posts...but no solution???

Post by Dr.CSS »

It usually has to do with { } in the template these are used by smarty to parce code so if you need to use something that has them you may need to wrap it in {literal} your thing {that has} these in it {/literal}...
knert

Re: Lots of Smarty Error posts...but no solution???

Post by knert »

Thank you for your quick reply. I think it's helpfull, but I could not figure it out  :-\

Here's the problem:

I use the basic template. On top in this template I placed a little PHP script. This little script is because I want certain pages to be secured. So when I want some pages to be secured (with login) I use this template.

The script that I use is:



There are indeed a "{" and a "}" in this script. So what you are saying is that these 2 parts are creating the error?

Is there any way to solve this then?

???
cyberman

Re: Lots of Smarty Error posts...but no solution???

Post by cyberman »

Edit your config.php, change value

Code: Select all

$config['use_smarty_php_tags'] = false;
to

Code: Select all

$config['use_smarty_php_tags'] = true;
Clear cache. Then you can use PHP inside a Smarty template like this
{php}
//prevents caching
header("Expires: Sat, 01 Jan 2000 00:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: post-check=0, pre-check=0",false);
session_cache_limiter();
session_start();

//this should the the absolute path to the config.php file
//(ie /home/website/yourdomain/login/config.php or
//the location in relationship to the page being protected - ie ../login/config.php )
require('/usr/local/psa/home/vhosts/xxxxxx/httpdocs/login/config.php');

//this should the the absolute path to the functions.php file - see the instrcutions for config.php above
require('/usr/local/psa/home/vhosts/xxxxxx/httpdocs/login/functions.php');

//this is group name or username of the group or person that you wish to allow access to
// - please be advise that the Administrators Groups has access to all pages.
if (allow_access(Administrators) != "yes")
if (allow_access(Users) != "yes")
{             

//this should the the absolute path to the no_access.html file - see above                                   
include ('/usr/local/psa/home/vhosts/xxxxxx/httpdocs/login/no_access.html');
exit;
}
{/php}
Another way is to put source inside a userdefined tag and call it in template like {your_tag}.
Last edited by cyberman on Thu Jan 18, 2007 10:13 am, edited 1 time in total.
knert

Re: Lots of Smarty Error posts...but no solution???

Post by knert »

Thnx so far! Yes indeed it looks better now, but not completely.  :'(

The problem now is that after the overall login in the secure area (with the pages that need to be secured too) I have to login in each page with this code.

I think this is because the code has changed a little bit so the login script does not recognize this code any more.

You talked about tags. Can I create a tag and place the original code in it? If so, can you reccomend me anything to create this tag?
cyberman

Re: Lots of Smarty Error posts...but no solution???

Post by cyberman »

Please look at admin panel to menu Extensions > Userdefined tag. There you can place original code (without . In template you can call it with name.
knert wrote: The problem now is that after the overall login in the secure area (with the pages that need to be secured too) I have to login in each page with this code.
Define another template for following pages (without your source) ...
knert

Re: Lots of Smarty Error posts...but no solution???

Post by knert »

I made a tag, put the code in it, gave it a name: login

the code:

//prevents caching
header("Expires: Sat, 01 Jan 2000 00:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: post-check=0, pre-check=0",false);
session_cache_limiter();
session_start();

require('/usr/local/psa/home/vhosts/xxxx/httpdocs/cms/login/config.php');

require('/usr/local/psa/home/vhosts/xxxx/httpdocs/cms/login/functions.php');

//this is group name or username of the group or person that you wish to allow access to
// - please be advise that the Administrators Groups has access to all pages.
if (allow_access(Administrators) != "yes")
if (allow_access(Users) != "yes")
{
include ('/usr/local/psa/home/vhosts/xxxx/httpdocs/cms/login/no_access.html');
exit;
}


Then I opened the template and placed on top:

{login}




{sitename} - {title}


{metadata}


{stylesheet}





     
     
         {title}
         {content}
     
     




Unfortenately I get the same thing: After login I have to re-login each time in the seperate pages with those template.

I DO know for a fact that each page MUST be .php. NOT .html. May be that's the problem?
Locked

Return to “CMSMS Core”