Page 1 of 1

[Solved] {if $node->alias == 'xx'}?

Posted: Tue Nov 09, 2010 3:59 pm
by Alain
Hello,

I need to make a conditional whereas a certain banner appears only on the home page, but nowhere else. So, I tried:

Code: Select all

{if $node->alias == 'home'}
		<div id="bannerBags"><div id="start"><a id="startBtn" title="Minimize header image" href="#">Start</a></div></div>
{else}
		<div style="display: none; clear: both;"></div>
{/if}
That didn't seem to work, as the banner didn't appear whenever one was on the home page.

I've also tried $node->id == '15', but to no avail.

Any idea how to fix this? Or rather, am I using the correct vars?

Re: {if $node->alias == 'xx'}?

Posted: Tue Nov 09, 2010 4:14 pm
by Wishbone
Try using:

{if $page_alias == 'home'}

Re: {if $node->alias == 'xx'}?

Posted: Tue Nov 09, 2010 4:14 pm
by Peciura
{$page_alias} is always available, as well as {content_id}

Code: Select all

{if $page_alias == 'home'}
	<div id="bannerBags"><div id="start"><a id="startBtn" title="Minimize header image" href="#">Start</a></div></div>
{else}
	<div style="display: none; clear: both;"></div>
{/if}

Code: Select all

{get_template_vars}
lists all available variables. One of them is {$content_obj}.
Look what properties it contains

Code: Select all

<pre>{$content_obj|@print_r}</pre>

Re: {if $node->alias == 'xx'}?

Posted: Tue Nov 09, 2010 5:45 pm
by Dr.CSS
{$node->.....} is only read by menu manager...

Re: {if $node->alias == 'xx'}?

Posted: Wed Nov 10, 2010 8:10 am
by Alain
Hello,

Yes indeed, I noticed later on. Pardon me.
Peciura wrote: {$page_alias} is always available, as well as {content_id}

Code: Select all

{if $page_alias == 'home'}
	<div id="bannerBags"><div id="start"><a id="startBtn" title="Minimize header image" href="#">Start</a></div></div>
{else}
	<div style="display: none; clear: both;"></div>
{/if}
That worked perfectly! Thank you!  :)