Check your version

This video covers a topic in Drupal 7 which may or may not be the version you're using. We're keeping this tutorial online as a courtesy to users of Drupal 7, but we consider it archived.

Function name suggestions

Video loading...

Join Drupalize.Me to watch this video

Join today and gain instant access to our entire video library.

Log in Sign up
  • 0:02
    Function Name Suggestions
  • 0:06
    with Joe Shindelar
  • 0:07
    In this chapter, we're
  • 0:09
    going to talk about a new feature for theming in Drupal 7.
  • 0:12
    This is Dynamic Theme Function Names.
  • 0:15
    It's similar to the Dynamic Template files that we talked about
  • 0:18
    in the Basic Theming series where we could create a node template
  • 0:21
    file like node--article.tpl.php.
  • 0:25
    And that would only be used when theming article nodes.
  • 0:29
    For some of the theme functions in Drupal,

Function Name Suggestions


In this video we cover a new Drupal 7 feature which lets us create suggestions for theme functions, in addition to suggestions for templates. We'll use this to modify the tags displaying on a node in our site.

In the example: $item['#options]['attributes'] += $variables['item_attributes_array'][$delta]; += is a shortcut for array_merge. So it is ensuring the contents of $variables['item_attributes_array'][$delta] are included in $item['#options]['attributes'] so that any class, rdf info or other html attributes are appropriate applied to the tag links. It's possible for any number of modules to set HTML attributes on the tags field in the theme we need to make sure that they get printed out appropriately.

Additional resources: