Recently I had the need to have different background images on different pages. With a non content management system this would not be that big of a deal. Since I needed the background images to cover the entire page and have the ability to specify which images, using a static body tag would not work. After some thought and research I was able to devise a solution using PHP.
1. Find an unique value that would be on each web page, such as the "Title" or the "Title Alias". I chose "Title Alias". This value has more of an interal use and I was already using the title field for my Seach Engine Friendly URL's. The jlleblanc at the Joomla forums were nice enough to provide me with the following code to locate the "Title Alias" value:
global $database; $id = mosGetParam($_REQUEST, 'id', 0); $row = new mosContent($database); $row->load($id); echo $row->title_alias;
2. I then took this value and entered it into a PHP statement that would generate my opening body tag. You will need to adjust the path of the background image file to fit your situation. I also commented out the echo $row-?title_alias; line. I do not need to print thisvalue to the screen.
<?php global $database; $id = mosGetParam($_REQUEST, 'id', 0); $row = new mosContent($database); $row->load($id); //echo $row->title_alias;
3. Change the value of the title alias in the joomla admintrator panel to the name of the background image file. This will need to be done for each web page that you want to specify the background image. You now have the ability to specify which background image gets used on which page.
4. Here is the output that is generated for each page: