How to get custom background (CSS) on index page?
PermalinkThe index page of my site is different than all other pages, and I would like it to have a slightly different background (all the other pages should have the standard site background). I assume that the best way to do this, is to add some CSS that is specific to that page, which will override the background on main.css.
I cannot find a place to do this.
I think it would be silly to have a separate theme just for this page, only to change the background.
Very grateful for any help. Thanks very much!
Andrey
Thanks,
Andrey
What part of the background do you want to change, the whole page or an element?
Steev
Andrey
For the whole page, for just 1 page, personally I would just add a bit of jQuery to an HTML block and use that to set the page background. There are no doubt other ways to do it, but that is the way I like to play.
Getting a bit more sophisticated, create a new view for the standard slideshow block so the image being shown (or group of images) are added as page backgrounds rather than just block backgrounds.
<?php if ($c->getCollectionID() == HOME_CID): ?> <style type="text/css"> body { background-image: url(<?php echo $this->getThemePath(); ?>/images/whatever.jpg); } </style> <?php endif; ?>
<body class="<?php echo $c->getCollectionTypeHandle()?>">
Then you can style body, body.home or any other page, body.about-us etc.
Below is for colour only.
<?php if ($c->getCollectionID() == HOME_CID): ?> <style type="text/css">body {background: #0CC;} </style> <?php endif; ?>
Place after theme styles and before the 'header_required' in the header.php or in the head of your template.
Thanks,
Andrey
<!-- Site Header Content //--> <link rel="stylesheet" media="screen" type="text/css" href="<?=$this->getStyleSheet('main.css')?>" /> <link rel="stylesheet" media="screen" type="text/css" href="<?=$this->getStyleSheet('typography.css')?>" /> <?php if ($c->getCollectionID() == HOME_CID): ?> <style type="text/css">body {background: #0CC;} </style> <?php endif; ?> <? Loader::element('header_required'); ?>
Thats how I got it to work.
Your code didn't work for me, I did this.
<body class="<?php echo $c->getCollectionHandle()?>">
The other 'Returns the page's handle'.
Which, now that I've looked at it, makes sense?
First one, affects all pages in a collection that have 'page' type, so all will have the same setting, for me = three pages.
Second one, affects the page by 'name', so in my case it worked on one page.
I'm still learning......
http://www.concrete5.org/marketplace/addons/backstretch/...
http://www.concrete5.org/marketplace/addons/background/...
http://www.concrete5.org/marketplace/addons/dojo-supersized/...
Thanks for all the answers, but I think I actually found a much easier way. I just added an HTML blog to the index page that contained regular background-image{} CSS. It did the trick. I added !important just for good measure.
Andrey
Thanks for all the answers, but I think I actually found a much easier way. I just added an HTML blog to the index page that contained regular background-image{} CSS. It did the trick. I added !important just for good measure.
Andrey
This will allow you to make for example a front_page.php copy of default.php (in your theme) and then re-structure the html and css in front_page.php however you need. You can then choose to use that page type for your homepage and you get the layout and css you need.
This link has more information
http://www.concrete5.org/documentation/general-topics/page-types...