using smarty

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
trick

using smarty

Post by trick »

I'm using htdig to index my site, but the problem is that it indexes the navigation menu, which confuses it a little bit. While the results are usually still pretty good, there not as good as they could be. So I want CMS to not display the navigation bar if the useragent has 'htdig' in it. would this work?

{if htdig}
{cmsmodule module='CSSMenu'}
{/if}

and then add as a user defined function for 'htdig'

if( instr($_SERVER['HTTP_USER_AGENT'],"htdig")!==false){ return true; }
return false;
arl

Re: using smarty

Post by arl »

I had a similar problem, I wanted to use the current page alias in a smarty if statement in my template. Like you, I tried to use a tag in the if-statement instead of a variable, but that did not seem to work and I cannot find anything about this in the smarty documentation. Perhaps it is just not possible?

What I did instead was to work around it. I use the tag to set a variable with the result and then use this variable in the if statement. You should be able to do something similar.

My tag {thispage}:

Code: Select all

global $gCms;
$smarty->assign('thispage',$gCms->variables['page_name']);
My template:

Code: Select all

{thispage}
{if $thispage == "xxxx"}
Some stuff here...
{/if}
It is not pretty, but it works... :-) Does anyone know of a more elegant solution?

Allan
alby

Re: using smarty

Post by alby »

trick wrote: I'm using htdig to index my site, but the problem is that it indexes the navigation menu, which confuses it a little bit. While the results are usually still pretty good, there not as good as they could be. So I want CMS to not display the navigation bar if the useragent has 'htdig' in it. would this work?

{if htdig}
{cmsmodule module='CSSMenu'}
{/if}

and then add as a user defined function for 'htdig'

if( instr($_SERVER['HTTP_USER_AGENT'],"htdig")!==false){ return true; }
return false;
try:
{if $smarty.server.HTTP_USER_AGENT != "htdig"}
....
{/if}

Alby
Last edited by alby on Thu Sep 08, 2005 2:15 pm, edited 1 time in total.
trick

Re: using smarty

Post by trick »

arl wrote: ....
My tag {thispage}:

Code: Select all

global $gCms;
$smarty->assign('thispage',$gCms->variables['page_name']);
My template:

Code: Select all

{thispage}
{if $thispage == "xxxx"}
Some stuff here...
{/if}
It is not pretty, but it works... :-) Does anyone know of a more elegant solution?

Allan
Thanks, I had tried this before, but I couldn't get it to work consitantly, it was acting incredibly weird. I finnally figured out why, The firefox UA switcher doesn't actually take effect until *after* the next page reload, so I was thinking my user agent was somthing it wasn't.
Locked

Return to “CMSMS Core”