By derek-morton on
Hello all,
I'm pretty new to Drupal and not very familiar with PHP and would appreciate some help with some PHP code.
In the Wilderness Theme page.tpl.php file there is the following php code:
if ($is_front):
endif;
This calls the CSS div "featured" which is an image to load if/when it is the homepage and when it isn't then the image is removed.
What I desperately need is a PHP code that says something like this:
if ($is_front):
elseif (node/xxx)
elseif (node/xxx)
elseif (node/xxx)
endif;
So that depending on which page/node of the website, a different CSS div is called and thus a different image can be used for each page.
Hope this makes sense and appreciate all your help. Thanks!
Cheers!
Comments
<?php if (arg(0) == 'node' &&
<?php
if (arg(0) == 'node' && !is_numeric(arg(xxx))):
HTML code
...
Depending on how much customization you need to achieve in these different pages (content types?), you could also create new node-xxx.tpl.php files which will be included in your page.tpl.php with your changes.
The theme guide is a great source of help even if you're not experienced with PHP. Hope this helps.
Thanks
I will give it a try and see what happens. The php just basically says, if (this node) then use this div, else if (this node) then use this div. The div's just being an image placement so that the image in the header is different for each page of the website. Thanks for the link will check it out.
Cheers!
Can't get it to work
Hi Daglees,
Okay, keep in mind I'm not a PHP expert but I can perhaps explain the just of it:
if (arg(0) == 'node' && !is_numeric(arg(1))):[div id="home-image"][/div]
elseif (arg(0) == 'node' && !is_numeric(arg(2))): ?>
[div id="about-us-image"][/div]
elseif (arg(0) == 'node' && !is_numeric(arg(3))): ?>
[div id="directions-image"][/div]
elseif (arg(0) == 'node' && !is_numeric(arg(4))): ?>
[div id="projects-image"][/div]
elseif (arg(0) == 'node' && !is_numeric(arg(5))): ?>
[div id="contact-image"][/div]
endif;Does this make sense to you? I know the code is incorrect but hopefully you can get what I'm trying to do :-)
I think this is what you want
Hope that helps.