This post describes how to achieve what is effectively the same as the WordPress is_page() method in Magento. Surprisingly I couldn’t turn up much on Google about this, so thought it was worth a blog post on how I did it.
I’m using a modified version of the jQuery backstretch plugin (posted here). I wanted the main product image to be shown as the background on each product page, but on CMS pages I wanted specific images to be displayed as the background for each page.
The issue is that the Javscript for the backstretch is included in the head, so you need to be able to establish in templates/page/html/head.pthml whether you are on a product page or a CMS page, and if you’re on a CMS page, which CMS page you are on.
Here’s how you do it;