User login

Drupal theming tip: theme_ functions you should NOT override

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.

Resolution

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

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.