Simplification of complex theme function #1 theme_status_messages.
Its one of the most heard complaints in the themeing corner of Drupal: that functions are faaar too complex. http://groups.drupal.org/node/716. And since I beleive the only workable way to achieve progression is to tackle the complex functions one a time: here is one.
This patch splits out theme_status_messages. And it uses a standard theme function to build a list: theme_item_list.
(patch made on a 4.7 system, but it applied correct to a HEAD)
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | theme_inc_simplify_status_messages.patch_0.txt | 1.63 KB | Bèr Kessels |
| theme_inc_simplify_status_messages.patch.txt | 1.62 KB | Bèr Kessels |
Comments
Comment #1
Bèr Kessels commentedhold the reviews. This is stupid: I copied the name of my theme in it. So it only works when testing on my theme :(. Ugh.
Comment #2
Bèr Kessels commentedSorry for the wrong patch above. This one is the correct one.
Comment #3
dries commentedTheme functions calling theme functions? Not sure about that.
Comment #4
Bèr Kessels commented«Theme functions calling theme functions?» I really dislike that too. But ATM that is the case all over Drupal.
If we now and here choose this is no longer "allowed", I think we do a very good step towards a better abstracted theme layer. But that would mean a great lot of work too. I hope we can pull this discussion to another place and time (oscom, themes.drupal.org).
Can you give concrete examples what functions you dont want to be called? Is it theme(item_list)?
What I did here, is make this function simpler. Not improve our theme model :).
Comment #5
Bèr Kessels commentedComment #6
eaton commentedHmmm. Why shouldn't theme functions call other theme functions? I've set up systems where an entire page might be themed, but the individual portions of it are split into their own thmee functiosn for easier granular overriding. It can be overdone, but I didn't realize it was something to be avoided in and of itself.
Comment #7
Bèr Kessels commentedLets get the focus back on the patch: Dries, what do you like to see changed in this patch? Is it too complex? Do you dislike the fact I use theme_item_list to build the item-list? is it the fact that I split out the messages and the compilation of these messages into separate functions?
Comment #8
Bèr Kessels commentedFWIW: since I beleive Dries touched an important point about nesting theme functions, I opened a thread about this in the theme group: http://groups.drupal.org/node/1082
Comment #9
drummhttp://drupal.org/node/65605