project blog

digital diary of diverse diversions

05 August 2007

Stub-Specific Body-Tag IDs for b2evolution

Written by Yours Truly ( Contact the author of this post )
Published on August 5th, 2007 @ 07:25:20 pm, using 288 words, 19346 views

A while back I found myself needing the ability to uniquely identify each blog on my b2evolution system. I wanted to be able to display blog-specific CSS styles and header imagery, while using the same b2evo skin across the entire site, rather than developing slightly varied skins for each blog.

The solution is rather simple, and allows each blog to be styled uniquely, while still allowing the remaining stylesheet definitions to cascade over elements which are not called by the unique identifier. So... on to the code...

Adding the following code to your b2evo skin's /skinname/_main.php file will cause the 'body' tag to be ID'd with the '$blog_shortname' of the specific blog. Essentially, this will ID the body tag as id=1 for Blog All, id=2 for Blog A, and so on....

The following code will work on b2evo 0.9.x...

<body id="<?php echo $Blog->disp( 'shortname' ) ?>">

...and the following code works in b2evolution 1.10.x...

<body id="blog<?php echo $blog ?>">

Once this code has been implemented in the _main.php file of your favorite b2evo skin, you can assign blog-specific styles to your CSS stylesheet as so:

body#blog2 #header {
background: #000 url(images/blog2header.jpg) top center no-repeat;
text-align: left;
}
body#blog3 #header {
background: #000 url(images/blog3header.jpg) top center no-repeat;
text-align: right;
}

The CSS style shown above works with the second PHP example, and can be used in b2evolution 1.10.x blogs...

Contemporaneous Auditory Narcotics:
or, What my speakers are currently pumping...
Decoder & Substance - Heist / Curvature

Creative Commons LicenseThis post is the creative work of Yours Truly and is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 License.

Bookmark this Post
b2evolution, b2evo, blog, body tag, PHP, code, stub, skin, CSS
scuttle co.mments Technorati del.icio.us digg SpyMy StumbleUpon backflip blinklist BlogMarks BlogMemes BuddyMarks Feed Me Links! FURL gravee Linkroll ma.gnolia netvouz Simpy Yahoo! My Web

Comments, Trackbacks, Pingbacks:

Comment from: Torben Email
I liked this a lot - thanks for providing it - for b2evolution 3.3.1 I changed the body tag to be:

<body id="blog <?php echo $Blog->ID ?>">
PermalinkPermanent Link 09/14/09 @ 00:09

This post has 102 feedbacks awaiting moderation...

Leave a comment:

Your email address will not be displayed on this site.
Your URL will be displayed.

Allowed XHTML tags: <p, ul, ol, li, dl, dt, dd, address, blockquote, ins, del, span, bdo, br, em, strong, dfn, code, samp, kdb, var, cite, abbr, acronym, q, sub, sup, tt, i, b, big, small>
(Line breaks become <br />)
(Set cookies for name, email and url)
(Allow users to contact you through a message form (your email will NOT be displayed.))

project blog

A journal containing the assorted projects and diversions which occupy my interest, including such things as Photoshop graphic design and standards compliant web design, web development, advanced css layouts, photography and photo-manipulation... whatever...




Choose skin

  • Switch to the route_53 skin
  • Switch to the december skin
  • Switch to the lush skin
  • Switch to the candleglow skin
  • Switch to the vastitude skin
  • Switch to the viper_flats skin
  • Switch to the underground skin
  • Switch to the wheelz_blue skin
  • Switch to the ravehands skin
  • Switch to the sojourn skin
  • Switch to the tunnel_vision skin

Miscellany

XML Feeds

Users Currently Online

  • Guest Users: 104

The Extras

Contact the admin     Engine: b2evolution     Hosting: Hostgator.com
Content Copyright ©2004-2013 TheDarksighed. All Rights Reserved.