Check parent page ID

Permalink
Hello,

I am trying to include a different header.php file if the page resides in a certain section of the site. For example…

if parent page id = about {
$this->inc('elements/header_about.php');
} else {
$this->inc('elements/header.php');
}

Does anyone have any clues as to how I would go about doing this?

Thanks for any direction you can give.

tabercreative
View Replies:
tabercreative replied on at Permalink Reply
tabercreative
I am currently using the following code to apply the top-level parent ID to the body of each page. I just can't figure how to apply a conditional function based on what it returns.

<?php 
global $c; $nh = Loader::helper('navigation'); 
$cobj = $nh->getTrailToCollection($c); 
$rcobj = array_reverse($cobj); 
if(is_object($rcobj[1])) { 
   $pID = $rcobj[1]->getCollectionID(); 
   $page = Page::getByID($pID); 
   echo $page->getCollectionHandle(); 
} else{ 
   echo $c->getCollectionHandle(); 
} 
?>
hutman replied on at Permalink Reply
hutman
You should be able to do something like this

$c = Page::getCurrentPage();
$parentPageID = $c->getCollectionParentID();
switch($parentPageID){
   case 1:
      //do homepage stuff
      break;
   default:
      //do default stuff
}