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.
| Attachment | Size |
|---|---|
| clean-body-section-classes.patch | 1.84 KB |

#1
Oops.
Check if $path is defined, otherwise front page gives us a crappy class.
Also my indentation was wrong.
#2
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.
#3
Committed to DRUPAL-6--2 with slight modification.
#4
Did I open a separate issue for the phptemplate_node_classes cleanup?
#5
Not sure, haven't you already done it?
#6
Have done now.
#7
Automatically closed -- issue fixed for 2 weeks with no activity.