Page 1 of 1
Smarty question
Posted: Wed Jun 04, 2008 9:32 am
by ahmednuaman
I'd like to check if the title of a page is something, for example if title is 'home'.
Is this the correct smarty syntax:
Code: Select all
{if title eq 'home'}<div></div>{/if}
Re: Smarty question
Posted: Wed Jun 04, 2008 10:47 am
by cyberman
You can check with {get_template_vars} inside your content if $title is available

...
Re: Smarty question
Posted: Wed Jun 04, 2008 10:49 am
by ahmednuaman
But {title} is a system tag; it's always available. How can I query if it's a certain word or not?
Re: Smarty question
Posted: Thu Jun 05, 2008 6:14 am
by cyberman
Yes, title is a tag but it's only like a included php file - it returns the value of title. It's not assigned to Smarty.
But you can do it
http://www.smarty.net/manual/en/languag ... on.capture
So you have to insert to your template
Code: Select all
{capture name='checktitle'}{title}{/capture}
{if $checktitle eq 'home'}<div></div>{/if}
Re: Smarty question
Posted: Thu Jun 05, 2008 6:54 am
by ahmednuaman
Cool thanks