I am trying to make a body_styles.module that will uses a combination methods to derive and insert id
and class
attributes into every page's body
tag. (see "How to generate body class/id attributes for each page" for more details)
My question is, is there a way for a module to insert code into the body
tag?
I keep thinking that hook_onload()
is the way to go here, but the problem (as I read it in the api) is...
The returned statements will be automatically separated by semicolons, so including them in the returned array is optional.
This prevents me from being able to use it to insert class
/id
, title
attributes. Or is there a better way than hook_onload()
for a module to insert code into the body tag? (This is my first module so I'm new to all the api hooks)
The body
tag is very special to css designers. The ability to insert class
and id
hooks gives us unbelievable control over the look of a site, usually mitigating the need for pounds of additional markup throughout the page. And this onload_hook
seems like the logical place to get a foothold.
If there isn't a better way to do this, would it be possible (and would people be amenable) to modify/extend hook_onload() in the core to allow us to insert other attributes like id
, class
, etc?
Comments
Still struggling with this.
Still struggling with this. Perhaps a more direct question:
How can I get my module to insert
class="foo"
inside the body tag?I'm trying to avoid users having to manually insert a function into their page template if possible.
-zach
------------------------
harkey design
: z