Post by john123 » Fri Feb 17, 2012 6:09 am

Hello,
Can anybody please tell me How Can I have different Background color (Body color) for HOME PAGE and OTHER PAGES in OPENCART site?

For Example: I want to use brown background in HOME PAGE and cream background in all other pages of site.
I can see in stylesheet.css
---------------------------------------------------------------
Body {
background: url(../image/.....png) repeat-x;
}
-----------------------------------------------------------------
From where I can only set only one background for all pages.

BUT I would like to use two different body-color(background) for HOME PAGE and OTHER PAGES.
Is that possible? How Can I do that?

Expecting help.

Sincerely,
-J

New member

Posts

Joined
Wed Sep 21, 2011 10:26 am

Post by dizarter » Fri Feb 17, 2012 7:37 am

File header.tpl in your theme folder (I am assuming you use default theme)

Find

Code: Select all

<body>
Replace with

Code: Select all

<body <?php echo (!isset($this->request->get['route'])) ? 'class="home-page"' : '' ?>>
This will attach CSS class "home-page" to body tag on home page.

BTW, never expect anything on free forums :)

New member

Posts

Joined
Tue Oct 11, 2011 7:33 am

Post by john123 » Fri Feb 17, 2012 9:05 am

hi dizarter,
It didn't work. I replaced the <body> in header.tpl with your code.
and created class 'home-page' in style sheet with different color background.
BUt it is not working.

BTW, I am using some different theme. If you want to see my header.tpl file I could provide you.

Thanks :)
-J

New member

Posts

Joined
Wed Sep 21, 2011 10:26 am

Post by dizarter » Fri Feb 17, 2012 10:11 am

CSS code should be something like

Code: Select all

body {
...
existing styles
...
}
body.home-page {
...
your-styles-here
...
}
As you see, this should come after existing styles for body, or it will get overwritten.

New member

Posts

Joined
Tue Oct 11, 2011 7:33 am

Post by john123 » Fri Feb 17, 2012 11:15 am

Thanks so much!!! dizarter.
SOLVED.

New member

Posts

Joined
Wed Sep 21, 2011 10:26 am

Post by suprazor » Wed May 23, 2012 11:35 am

Tried that and it works on "yourdomain.com/" and ".com/index.php" but on ".com/index.php?route=common/home" it takes the style from body instead. Whats the fix for that?

Newbie

Posts

Joined
Thu May 03, 2012 4:17 am

Post by J15Allen » Sun Nov 25, 2012 1:53 am

Did anyone find a solution?
Have the same problem as post above.

Works with ".com/index.php" but on ".com/index.php?route=common/home" it takes the style from body.

Newbie

Posts

Joined
Sun Nov 25, 2012 1:19 am

Post by loftytemplates » Sat Feb 16, 2013 2:16 pm

try this it will work

<?php if(!isset($this->request->get['route']) or $this->request->get['route']=="common/home"){?> class="your-class" <?php }?>


Posts

Joined
Wed Jan 16, 2013 9:01 pm

Post by settysantu » Sun Feb 17, 2013 1:11 am

I think this module will make your work easer http://codecanyon.net/item/custom-backg ... el/2902104

User avatar
New member

Posts

Joined
Mon Jan 03, 2011 11:59 am
Location - Hyderabad, India
Who is online

Users browsing this forum: No registered users and 19 guests