How to change an image based on the page title
Posted: Wed Dec 16, 2009 4:15 am
Hello,
Hopefully someone will be able to give me a hand. I'm developing my first theme for drupal and got stuck trying to add some php to dynamically change an image in a div according to the page's title. Drupal by default will create a variable called $title which is a string with the page's title. So I want to check: If $title is title1, use image1_png. The code I've created is:
Can someone tell me what am I doing wrong? I'm very new to php and can't see to work out...
Thanks in advance!
Hopefully someone will be able to give me a hand. I'm developing my first theme for drupal and got stuck trying to add some php to dynamically change an image in a div according to the page's title. Drupal by default will create a variable called $title which is a string with the page's title. So I want to check: If $title is title1, use image1_png. The code I've created is:
Code: Select all
<?php
$title = "title1";
$gd_image = "images/side_gd.png";
if ($title == "title1") {
<img src="<?php echo htmlspecialchars($gd_image); ?>"/>
else { <img src="image/other.png"/>
}
?>
Thanks in advance!