add body classes based on visible sections

joachim - July 13, 2009 - 12:45
Project:Clean
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

This adds body classes to allow styling by section.

Eg, for the path /section/subsection/page
creates: path-section, path-section-subsection, path-section-subsection-page

I'm taking this to three levels -- it's easily changed in code to more or fewer. I pondered making this a setting but probably not worth the faff.

I'm using REQUEST_URI to get the actual URL that's been typed in, so the section is defined by what the user thinks they are seeing.

It might also be an idea to add a body ID based on the real, full path, but I made phptemplate_body_classes return data rather than pass $vars by ref to match the node classes function -- so not sure how best to tackle that.

AttachmentSize
clean-body-section-classes.patch1.84 KB

#1

joachim - July 13, 2009 - 12:50

Oops.

Check if $path is defined, otherwise front page gives us a crappy class.
Also my indentation was wrong.

AttachmentSize
clean-body-section-classes-2.patch 1.88 KB

#2

joachim - July 13, 2009 - 14:13

And another patch:
- body ID
- pass in $vars by ref

As discussed on IRC, the getting of the $path needs tidying up.

Also, once we commit this, I think phptemplate_node_classes should be changed to pass by ref too so the two functions are consistent.

AttachmentSize
clean-body-section-classes-3.patch 2.68 KB

#3

psynaptic - November 22, 2009 - 14:13
Status:active» fixed

Committed to DRUPAL-6--2 with slight modification.

#4

joachim - November 22, 2009 - 18:02

Did I open a separate issue for the phptemplate_node_classes cleanup?

#5

psynaptic - November 26, 2009 - 10:40

Not sure, haven't you already done it?

#6

joachim - November 26, 2009 - 13:54

Have done now.

#7

System Message - December 10, 2009 - 14:00
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.