Page 1 of 1

php if statment help - page id?

Posted: Wed Nov 21, 2007 10:00 am
by itsc.net
Hi guys,

I'm trying to insert the following code into my template which will show a sidebar dependant on the page your looking at

Code: Select all

<div id="sidebar">
<?php 
	if ($body=='index') 
		{echo ' {global_content name='home-sidebar'} '} 
	elseif ($body=='about-us') 
		{echo ' {global_content name='about-sidebar'} '}  ...etc....etc ....etc
      ?>  
</div>

my problem is that i'm not sure how to get the body/ page id? I'm sure this must be set in the database to call the content etc dependant on the page.


can anyone tell me how to assign a body/page id or where to get this info?

many thanks in advance  :)

Re: php if statment help - page id?

Posted: Wed Nov 21, 2007 1:31 pm
by alby
itsc.net wrote: I'm trying to insert the following code into my template which will show a sidebar dependant on the page your looking at
.......
Use $page_alias variable:

{if $page_alias == 'home'} This is the Homepage
{else if $page_alias == 'about-us'} This About us
{else} Other page
{/if}

Alby

Re: php if statment help - page id?

Posted: Wed Nov 21, 2007 1:37 pm
by itsc.net
thanks man :)