Welcome, Guest. Please login or register.
Did you miss your activation email?
May 27, 2012, 04:25:26 AM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
155555 Posts in 21715 Topics by 7737 Members
Latest Member: gx-world
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: content only on certain pages?  (Read 590 times)
gilly

Offline Offline

Posts: 49


« on: March 29, 2008, 05:39:47 AM »

Hi, what I want to do is have a sidebar that, on the homepage, shows news items (anynews module), and any other pages shows other content (eg photos).

This is essentially what I want to do below, but don't know the exact syntax:

Code:

<?php 
   
if(HOME_PAGE) { 
      
display_news_items(); 
   else
      <
h2>photos</h2>
      <
img src="">etc
   
}

?>


If anyone could help out here that would be great!
Logged
kweitzel
Forum administrator
*****
Offline Offline

Posts: 6977


WWW
« Reply #1 on: March 29, 2008, 09:14:25 AM »

The Homepage usually has the page_id = 1 (unless you deleted or reordered your pages).

So a simple "switch case" construct should do:

Code:
<?php

switch (PAGE_ID) {

  case 
display_news_items(); break;
  default : echo 
'<img src ....'; break;
}
?>


obviously you can change the PAGE_ID to whatever your Homepage is ...

cheers

Klaus
Logged

WebsiteBaker Org e.V. - for WebsiteBaker

gilly

Offline Offline

Posts: 49


« Reply #2 on: March 31, 2008, 03:21:34 AM »

thanks Klaus, that works well!
Logged
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!