Page class suffix to change background image in the body

Everything to do with Joomla! 2.5 templates and templating.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
kjphilips
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Tue Oct 27, 2009 11:13 am

Page class suffix to change background image in the body

Post by kjphilips » Fri May 27, 2011 4:26 am

Hello and thank you for reading this...

I have been trying to do this for a few hours now and I cant figure it out.

I want to set a background image for my index page I am trying to do this by using the page class Menus > Main Menu > Home > Page Display Options in the box labeled Page Class

I enter the suffix with a leading space index

my css code looks like this

.background {position: absolute;width: 100%; background: #E8E1CE url(../images/bg.jpg) 0 0 repeat-x;}

.background.index {position: absolute;width: 100%; background: #E8E1CE url(../images/bgHomePage.jpg) 0 0 repeat-x;}

my index.php file looks like this

<body class="background index">

I have tried everything I can think of and no avail. I have read articles about placing custom php code in the head and adding an include referencing the default class but it throws errors.

I need some help and an explanation please... before the rest of my hair turns grey!

Thank you.

lucifersameer
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Jun 09, 2010 2:33 am

Re: Page class suffix to change background image in the body

Post by lucifersameer » Fri May 27, 2011 8:44 am

Hi KJPhilips - I have EXACTLY the same problem. Did you get this resolved? Would be great if you could guide me.

thanks in advance.

kjphilips
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Tue Oct 27, 2009 11:13 am

Re: Page class suffix to change background image in the body

Post by kjphilips » Fri May 27, 2011 9:08 am

Unfortunately I have not as of yet been able to figure this one out, I hope that someone here can direct me. I have read all of the documents in the wiki and although I don't consider myself an expert in css I am at least a novice! Seeing as I do this as a hobby in my spare time I am thinking I should switch to fishing! ;)

lucifersameer
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Jun 09, 2010 2:33 am

Re: Page class suffix to change background image in the body

Post by lucifersameer » Fri May 27, 2011 9:26 am

HA HA HA ! The BIG difference between Fishing and Software is that NOTHING is impossible in software. I'm sure a lot of Joomla Gurus will second me on this.

I'm putting together a detailed query for the folks here. I'm sure someone can help us out.

kjphilips
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Tue Oct 27, 2009 11:13 am

Re: Page class suffix to change background image in the body

Post by kjphilips » Fri May 27, 2011 9:35 am

Yea my skills with the various languages produce results where as my skills with a fishing rod produce nothing! Thankfully I don't have to fish for my meals or I would be a very very thin man! :p I am still looking for the answer I am on hour 6, I will post here if I figure it out. If you find the solutions could you please PM me or something. Thanks for the comments it is nice to know I am not alone! :D

lucifersameer
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Jun 09, 2010 2:33 am

Re: Page class suffix to change background image in the body

Post by lucifersameer » Fri May 27, 2011 9:40 am

No Problemo Amigo ! I've just put in a new post. Check it out - maybe my issue might not be exactly like yours, but all solutions will help.

kjphilips
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Tue Oct 27, 2009 11:13 am

Re: Page class suffix to change background image in the body

Post by kjphilips » Fri May 27, 2011 10:46 am

OK I found the answer... and it looks as if this will work

Code: Select all

<?php
$app = JFactory::getApplication('site');
$pageclass =  & $app->getParams('com_content');
?>
and I replaced the body tag with this

Code: Select all

<body class="<?php echo $pageclass ->get('pageclass_sfx'); ?>">
in the menu items properties I used the suffix for the alternate style I wanted to use. I found that if i used the space before the suffix it didn't work so I put in the page class with NO space

The post I saw with this code said that this was the way to do it for Joomla 1.6

I would like to thank Mr. designsubway for his solution...

now I would like to know if there are any security issues with this regarding what I read in the Using the Page Class Suffix in Template Code tutorial about always using htmlspecialchars

lucifersameer
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Jun 09, 2010 2:33 am

Re: Page class suffix to change background image in the body

Post by lucifersameer » Sat May 28, 2011 7:23 am

Hey KJ - I think that's exactly what is the solution. However I've decided to migrate away from Joomla for my project. Primarily due to IE and its incompatibility with some of extensions.

raynix
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Wed May 11, 2011 1:23 am

Re: Page class suffix to change background image in the body

Post by raynix » Wed Oct 26, 2011 6:03 am

This works. Thanks. :laugh:

dontflinch
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Sun Mar 06, 2011 2:03 am
Location: US

Re: Page class suffix to change background image in the body

Post by dontflinch » Sat Sep 29, 2012 4:10 pm

thanks!
kjphilips wrote:

Code: Select all

<?php
$app = JFactory::getApplication('site');
$pageclass =  & $app->getParams('com_content');
?>
and I replaced the body tag with this

Code: Select all

<body class="<?php echo $pageclass ->get('pageclass_sfx'); ?>">


Locked

Return to “Templates for Joomla! 2.5”