Page 1 of 1
using smarty
Posted: Wed Sep 07, 2005 7:45 am
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;
Re: using smarty
Posted: Wed Sep 07, 2005 8:21 pm
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
Re: using smarty
Posted: Wed Sep 07, 2005 9:47 pm
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
Re: using smarty
Posted: Fri Sep 09, 2005 1:51 am
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.