[drupal-devel] Improve Drupal themability
All, to improve theming of drupal I would like to introduce two new functions, which are theme_list() and theme_list_item().. function theme_list($items = array(), $id) { if (isset($items)) { $output .= '<ul id="'. $id .'">'; foreach ($items as $item) { $output .= theme('list_item', $item); } $output .= '</ul>'; } return $output; } function theme_list_item($item, $class = NULL) { return '<li class="'. $class .'">'. $item .'</li>'; } These two functions will help us, theme drupal. Every list is getting a unique id like $module-$method. For example we get: <ul id="book navigation"> <li class="leaf"><a href="#">...</a></li> <li class="leaf"><a href="#">...</a></li> <li class="leaf"><a href="#">...</a></li> </ul> With these two functions we can get all hardcoded lists (<ul><li>) out of drupal.. At the end, a lot of theme function will be deprecated. you can think about theme_status_messages(), theme_node_list(). Combining this with the modified theme_box()-approach of Ber Kessels (http://drupal.org/node/15332) we can theme almost anything we want and how we want, with less extraneous markup.. I would like to know what you guys think about this, and dicuss before having some major patches hitting the patch queue.. Stefan.
We already have theme_item_list(). If you need more features from it, please submit a patch.
about theme_status_messages(), theme_node_list().
theme_node_list() and theme_user_list() are useful wrapper functions for theme_item_list(). They are useful because the themer themer knows what type of data he is dealing with and can universally style accordingly. Consider prefixing all blog posts with a special icon, or prefixing every user with an online/offline indicator. That is easy to do today but would be hard if you you go to a your proposed scheme.
Op 14-apr-05 om 15:34 heeft Moshe Weitzman het volgende geschreven:
We already have theme_item_list(). If you need more features from it, please submit a patch.
about theme_status_messages(), theme_node_list().
theme_node_list() and theme_user_list() are useful wrapper functions for theme_item_list(). They are useful because the themer themer knows what type of data he is dealing with and can universally style accordingly. Consider prefixing all blog posts with a special icon, or prefixing every user with an online/offline indicator. That is easy to do today but would be hard if you you go to a your proposed scheme. Why would that be hard? Every block has a unique id..
With the approach I took, it is just as easy to theme the things you mentioned above. the only things is, that we do not add more markup as strictly needed, but ofcourse your always free todo whatever you like in your themes. Stefan.
Stefan Nagtegaal wrote:
Op 14-apr-05 om 15:34 heeft Moshe Weitzman het volgende geschreven:
We already have theme_item_list(). If you need more features from it, please submit a patch.
about theme_status_messages(), theme_node_list().
theme_node_list() and theme_user_list() are useful wrapper functions for theme_item_list(). They are useful because the themer themer knows what type of data he is dealing with and can universally style accordingly. Consider prefixing all blog posts with a special icon, or prefixing every user with an online/offline indicator. That is easy to do today but would be hard if you you go to a your proposed scheme.
Why would that be hard? Every block has a unique id..
Um, I have to find out all those IDs. And when I add a new module, I have to know that its block or page has a user list and add that to my stylesheet. theme_user_list() allows the themer to once and for all define how a user list should be displayed. Considering that your theme expert is sometimes unavailable after the site is launched, I think the theme function approach is worthwhile. Note that these 2 approaches are not incompatible. Everything runs through theme_item_list() today. So just add your proposed logic there. I just want to refute your notion that theme_node_list() and its friends would be deprecated by your proposed change. They won't be.
Op 14-apr-05 om 15:47 heeft Moshe Weitzman het volgende geschreven:
Stefan Nagtegaal wrote:
Op 14-apr-05 om 15:34 heeft Moshe Weitzman het volgende geschreven:
We already have theme_item_list(). If you need more features from it, please submit a patch.
about theme_status_messages(), theme_node_list().
theme_node_list() and theme_user_list() are useful wrapper functions for theme_item_list(). They are useful because the themer themer knows what type of data he is dealing with and can universally style accordingly. Consider prefixing all blog posts with a special icon, or prefixing every user with an online/offline indicator. That is easy to do today but would be hard if you you go to a your proposed scheme. Why would that be hard? Every block has a unique id..
Um, I have to find out all those IDs. And when I add a new module, I have to know that its block or page has a user list and add that to my stylesheet. theme_user_list() allows the themer to once and for all define how a user list should be displayed. Considering that your theme expert is sometimes unavailable after the site is launched, I think the theme function approach is worthwhile.
Note that these 2 approaches are not incompatible. Everything runs through theme_item_list() today. So just add your proposed logic there. I just want to refute your notion that theme_node_list() and its friends would be deprecated by your proposed change. They won't be.
Don't forget that the classes do _not_ have to be unique so the classes will stay to theme things the way it was.. But, I am only introducing an required id to the <ul> which let us do the same as we did before on the surrounding <div>. Maybe it's Stefan
participants (2)
-
Moshe Weitzman -
Stefan Nagtegaal