I am working on a module to provide Manifest file support for Drupal. However, that hinges on being able to stick a manifest='whatever' attribute into the html element. At present, there is no way to do so via either the core html.tpl.php file or the html5_tools replacement.

While I could probably hack something together, probably along the lines of "be sure to put this print statement in your template", I'd much rather have a common solution. Since people who want a Manifest file are probably using html5_tools anyway, is that something that this module could just bake into its alternate template file? Please? I should be able to handle the rest; I just need a way to get the manifest attribute into the template.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ericduran’s picture

I don't see why not.

What would you like us to do?

We could wrap an if statement around your manifest variable, or we could provide and empty default, and always print it, assuming you're variable would overwrite the real value.

Your call, just let me know or just provide a patch ;)

bleen’s picture

I think we'd definitely want to use a generic solution here so the next module that comes along can add attributes as well. Maybe we create an $attributes variable and then call a simple drupal_alter() on it? Thoughts?

Crell’s picture

Having an $html_attributes array that gets flattened to a series of attributes would be ideal. I can then stick a manifest attribute in there via a preprocess, and whoever else finds they need to stick something else in there can do so as well.

And people using a theme that doesn't inherit from that template, well, they can implement the same feature if they want my module to work. :-)

/me makes a note to bug JohnAlbin about Zen...

drnikki’s picture

plus one.

ericduran’s picture

Ok, this should be in rather soon.

This is what I got so far:

Other modules need add attributes to the $variables['html_attributes'] in the html preprocess hook just like you would with any other attributes.

So $variables['html_attributes']['manifest'] = 'my url';

We're flattening that in a different variable called $html_extra and printing that in the html.tpl.php template.

I should have a patch up pretty soon, just testing and documenting.

Crell’s picture

That would work for me. I just talked to JohnAlbin and he's halfway doing something similar in Zen, I think. It's probably best to touch base to make sure everyone' using the same variable names. (I personally don't care what they are, just that we're consistent so the module works on any base theme.)

ericduran’s picture

Here's the patch if anyone wants to review feedbacks are always welcome.

I'll talk to JohnAlbin before committing this assuming everyone is ok with it.

rupl’s picture

This is hot!!

Another use case: some JS libraries like to see a "no-js" class in <html> and right now that isn't possible without custom templates. Right now Modernizr module is doing gymnastics to load and execute properly and this will simplify things.

bleen’s picture

any word from JohnAlbin on the variable name?

Personally I would have gone with something like "html_tag_attributes"

ericduran’s picture

Yes, I spoke to JohnAlbin yesterday after uploading the patch. He also thinks the variable name might need to change to make it work with zen but he said he'll get back to us on the Ticket.

So we'll give him some time.

JohnAlbin’s picture

Status: Active » Needs review
FileSize
2.13 KB

Here's an updated patch that uses a $html_attributes_array and $html_attributes variable in the same way as core uses $title_attributes_array/$title_attributes, etc.

I've just added this same capability to Zen with the same variable names as this patch.

ericduran’s picture

Status: Needs review » Fixed

Everyone thanks for the fast feedback on this issue.

This is now fixed. -- http://drupal.org/commitlog/commit/15150/024822c776559ba18d2a6d46692f6df...

Crell’s picture

Yay! Thanks, everyone. Back to coding...

Status: Fixed » Closed (fixed)

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