I've checked the function reference, but can't find anything that lets me write a conditional statement in e.g. header.php as follows:
`
if (is_home_page()) {
// do something
} else {
// do something different
}
`
I know I can create a separate index.php file, but it would be neater to have e.g. a single header file that loads e.g. different scripts or styles depending on the context.
Thanks
Comments
In general you have to use the object model to differ album, image or Zenpage page/news contexts. Zenpage items however have `is_Pages()` and `is_News()` for hte `pages.php` and `news.php` pages.
See the user guide about a tutorial for that. I assume you have read the theming tutorial already.
Also - is there any way to distinguish between index.php and a separate home page like index-gallery.php?
I have index.php for my 'splash' page and index-gallery.php for my album overview - but `$_zp_gallery_page` equals index.php for both.
I could get into finding a string in the URL but that's a bit messier.
To recap, I have a home/splash page (`index.php`) distinct from my gallery index page (`gallery-index.php`) - and I want them to have different body classes, so that the splash gets a background image, and the gallery index doesn't.
In Zenphoto, the `$_zp_gallery_page` global resolves to 'index.php' on both pages.
So:
`
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
$gallery = strpos(curPageURL(), 'gallery');
?>
>
`
If `$_zp_gallery_page` is 'index.php' AND the page URL does not have 'gallery' in it, add the class 'home' to the body element.
Note that if you have called your gallery index page something else like 'overview', you will have to substitute 'gallery' for 'overview'.
If anyone has a more elegant solution I'd be keen to hear it. What we really need is a pair of functions like in Wordpress: `is_home()` and `is_front_page()`. ;-)
Here it is working: http://jaslehalphotography.co.uk/
In this case it is a normal custom page and should like like one. `$_zp_gallery_page` should really return `gallery-index.php`. It does this with all custom pages (archive.php,contact.php,gallery.php of the Zenpage theme) I just tested to be sure.
You can also test manually for `$_ GET['p']`.
Btw, you are running on the older 1.3 release. The 1.3.1.x release were security bug fix releases and we strongly recommend to upgrade.
PS: Nice site. You should submit to the showcase. Small suggestion: I would implement mousewheel support for the thumbs (I see it is loaded actually but in Firefox & Safari 4.1.2 it does not work):
`$_zp_gallery_page` returns 'index.php' on both pages. However `$_GET['p']` is useful. So now I have in `header.php`:
`
>
`
which is neater.
I will update - and submit to showcase. Thanks for heads up on mousewheel - it will be related to the jQuery version I expect.