What’s the difference between using the two options below to output link HTML?
theme('links', $primary_links, array('class' => 'links primary-links'))
theme_links($primary_links, $attributes = array('class' => 'links primary-links'))
Many thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
On a default Drupal installation without any template customizations they will output the same thing.
However, the
theme()function is essentially a wrapper for the theming system in Drupal. By passing ‘links’ as the first parameter, you are telling Drupal to look for the links theme whether this be a function or a template. In this case the theme is a function (theme_links()) which gets called.If you would want to make changes to the theme, you could do so by overriding it. For example you could create the function
myTheme_links()and have it override the defaulttheme_links(). If you are calling the functiontheme_links()directly, you would have to change this code to the appropriate theme function. However, if you used thetheme()function, there wouldn’t be any additional change since this function knows when themes are overridden and takes the appropriate action. In a nutshell, using thetheme()function is the more flexible solution for future proofing your code and probably considered the Drupal way of doing things.For more information on theming, check out Drupal’s theme documentation.