Drupal theming tip: theme_ functions you should NOT override

By Benjamin Melançon
on 12 Aug
0 comments

Key words and phrases

theme override don't menu item listing do not do it that way menu_list theme_list_item theme_menu_list theme_item_list

Tags

Description

Theme functions are designed so that they can be overridden, but the building block theme functions provided by Drupal core should be left alone.

In discussion with a colleague, who provided all the insight paraphrased below, talking about some of the Drupal gotcha's we've seen get talented people not sufficiently indoctrinated into the Drupal way.

With one site, the designer overrode a ton of theme functions.

Like lists. So now menu_list is no longer an ordered list but a gathering of content

By overriding the default theme, we don't mean a theme in this case but rather the core theme functions.

item_list is used ALL THE TIME.

It's a core way of doing lists.

And so when the designer overrode the core list theme, which had a global effect... the navigation block, menu blocks, views, etc, all wrecked

Of course all the resulting HTML, CSS and theming was then built up around this cut of Drupal's proverbial hamstring.

Overriding the core theme function was not the way to make changes in this case, though you can see where the temptation would be on that. But it is a temptation you must resist! For all the reasons described.

Just create a non_list and use that when needed.

It's just a matter of figuring out where farther up the chain you can make the default not called.

This should be in an introduction to Drupal theming: these are the functions that *can* be overridden, but *should not be*

All the lower level ones.

 

Post new comment
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <small> <pre> <strike> <sub> <sup> <kbd> <s>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.