With the discussion to remove a lot of default styling from core and putting the class names and other attributes in the hands of the themers/designers. I am thinking an official attributes array is in order for theme functions.
This would be an array for all theme functions that contains all the attributes that are intended to be added to a block element. The structure would be something that drupal_attributes() could process for the final output. The idea is that module developers would be able to add classes for unobtrusive javascript, blocks would be able to add classes in the admin area, and the end theme would be able to sort through these attributes fairly easily.
Ideally this would be accessible via preprocess and module developers would use it only as needed for functionality purposes. I imagine it formatted something like this:
<?php
function phptemplate_preprocess_hook($vars) {
$vars['attributes_raw'] = array(
'class' = array('class-1', 'class-2'),
'id' = 'id-for-element',
'title' = 'title for the element',
);
$vars['attributes'] = drupal_attributes($vars['attributes_raw']);
}
?>I realize that the drupal_attributes() function would have to be modified to handle class as an array, but I feel this is easier to deal with than a single string.
Now, this is a raw thought and I am sure that this needs work before it can be considered as a final proposal. I am hoping this leads to a good way to allow module writers to give classes to elements and still allows us to maintain control. I also feel it is a good start towards letting admin configurable classes for blocks that has been mentioned before.
Comments
Also, I am posting this here
Also, I am posting this here first so that it can be hashed out and made solid before posting it as an issue to Drupal 7.
this would be really useful
I like classes as an array. That would be much easier than exploding a string every time you need to play with the class list.
--
d.o: canarymason
twitter @canarymason
--
d.o: canarymason
twitter @canarymason
menu_attributes
Do you think it might be worth building off of http://drupal.org/project/menu_attributes to include the same kind of support for blocks, that modules can hook into?
This is what it looks like in a node (looks the same in menu settings too)
Yes, that is one
Yes, that is one possibility. The idea is for creating a standard way for modules and various other parts of the system to add identifying information to the elements in the theme layer, whether it be for styling or for javascript purposes.
I think it would be preferable to do it this way than to be hard coding the attributes. This really opens the door to add these via the backend of Drupal or programatically if it is needed for javascript. And since it is in an array, it allows the themer or designer to ignore these classes, trim them down, add to them or just drop them in wholesale without having to dump another tpl into the theme.
I think it opens doors to some of the functionality talked about during Drupalcon.
I missed drupalcon...
so I'm a little in the dark on some of that discussion, but I really like general idea of having attributes available in arrays by type. I can imagine some really cool possibilities that it could allow for like:
I'm probably getting ahead of myself, but I think the basic functionality would be a huge improvement, and could ultimately be a great thing for Drupal.
This looks like a good
This looks like a good starting place, but I'd like to see classes and style definitions be stored as arrays.
--
d.o: canarymason
twitter @canarymason
--
d.o: canarymason
twitter @canarymason
i would think that is a
i would think that is a pretty easy patch to the function itself. The hardest part would be to make sure all the uses of it are ported also.
Amazing stuff.
Zarabadoo, this is a much needed step towards standardization and better integration between the theming layer and the back end.
Would you take a stab at writing a first draft of what the array spec would look like? Let's post it as a wiki page, so that folks can contribute to it.
Thanks,
@modulist
@modulist
Apparently this discussion
Apparently this discussion has been going on for a while.
Check it out: http://drupal.org/node/306358