Swap header graphic on pages using php and inline css

selwynpolit - April 8, 2009 - 16:20

In my theme, I have some php code in page.tpl.php that looks at the $uri and displays a different background header image depending on the page the user visits. The code is listed below. This works fine except for one particular page. The page is node/add/info-request. This is a page that allows the user to fill out a form (created with cck.) There is nothing obviously different about the html that is generated. The theme is a modified version of the theme burnt. Does anyone have any suggestions as to why this should not work?

<div id="container"

<?php
$uri = explode("/", substr($_SERVER['REQUEST_URI'], 1));

if ($uri[0] == "educational-program-resource-catalog" ){
  //print educ header
  print " style=\"background-image:url(sites/all/themes/burnt/header-graphic-edu.jpg);background-repeat:no-repeat; \">" ;
}
else if($uri[0] == "guard-story" ){
  //print "guard header" ;
  print " style=\"background-image:url(sites/all/themes/burnt/header-graphic-rrf.jpg);background-repeat:no-repeat; \">" ;
}
else if ($uri[0] == "node" )
{
  //print "node add header - for contact form" ;
  print " style=\"background-image:url(sites/all/themes/burnt/header-graphic-edu.jpg);background-repeat:no-repeat; \"> <p> test this</p>" ;
}
else{
  //print "home header" ;
  print " style=\"background-image:url(sites/all/themes/burnt/header-graphic-edu.jpg);background-repeat:no-repeat; \">" ;
}
...

You might want to check out

nevets - April 8, 2009 - 17:10

You might want to check out the header image module for an alternative approach.

 
 

Drupal is a registered trademark of Dries Buytaert.