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

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.
Post Reply
User avatar
Alain
Forum Members
Forum Members
Posts: 17
Joined: Wed Oct 13, 2010 11:35 am

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

Post 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?
Last edited by Alain on Wed Nov 10, 2010 8:10 am, edited 1 time in total.
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

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

Post by Wishbone »

Try using:

{if $page_alias == 'home'}
Peciura

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

Post 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>
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

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

Post by Dr.CSS »

{$node->.....} is only read by menu manager...
User avatar
Alain
Forum Members
Forum Members
Posts: 17
Joined: Wed Oct 13, 2010 11:35 am

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

Post 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!  :)
Post Reply

Return to “CMSMS Core”