Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Background image on Special pages help with CSS or code?
#7
sarnaiz Wrote:
sal Wrote:In my GetSimple templates, on the body element I usually add an ID using the page's slug (like you do, however I prefix mine with "d-" to avoid ID collisions) and also add the page's parent slug as a class (also prefixed with "p-") which helps to style sections .

Code:
<body
  id="d-<?php echo get_page_slug(false); ?>"
  class="p-<?php echo (get_parent(false) != '') ? get_parent(false) : 'orphan' ?>">

(I've put the attributes on their own line here for readability, they'd normally be on the same line. I also add the body's ID as a class in an effort to avoid the (apparent) bad practice of using ID's in CSS selectors.)

So say you had that in place, it would just be a matter of tweaking your CSS to this:

Code:
#d-news, .p-news {
    background: url(/data/uploads/siteImgs/bkgrd-news.jpg) no-repeat  top left;
}

So each news page is getting an id, but that's the solution, adding a class so that I don't have to have a line of css for every id that is generated as a new page is created. Duf! *forehead slap* Using the parent page as the class is even better!!!

Where would I add this? In the head.inc.php file?

Woohoo! Worked like a charm.

<body
id="<?php get_page_slug(); ?>"
class="p-<?php echo (get_parent(false) != '') ? get_parent(false) : 'orphan' ?>">

I used this so that I still get my id and it adds the class of the parent name. I liked your use of the prefix.

#news, .p-news {
background: url(http://s418104665.onlinehome.us/data/upl...)no-repeat top left;
}

Thank you for your help Sal.
Reply


Messages In This Thread
Background image on Special pages help with CSS or code? - by sarnaiz - 2012-09-26, 22:00:14



Users browsing this thread: 1 Guest(s)