5

i am intermediate in php.i start learning drupal 7 theme system. i need to know what is role of $title_prefix and $title_suffix variable inside .tpl.php files. what happen if we not include these variable inside .tpl.php files. i also read documentation for those variable at drupal.org but documentation is not enough to make it crystal clear.can anybody explain its use in simple words.

1 Answer 1

9

I'm not sure how it could be any clearer than on the docs page, but here goes;

  • $title_prefix is for content that should be displayed directly before the title in a template file (node.tpl.php, block.tpl.php, etc).
  • $title_suffix is for content that should be displayed directly after the title in a template file.

There really is nothing more to it than that. If you choose not to include these variables in your template file then they simply won't be rendered.

Since any module/theme in the system has the chance to populate/change the values that are in either of these variables it's impossible to say exactly what will not be rendered in your particular case if you choose not to display them.

As an example, (and if I remember rightly), contextual links for blocks/nodes are contained in the $title_prefix variable. So if you don't print $title_prefix in your template, you won't get contextual links for that item.

1
  • Jut one thing: Contextual links are rendered in the $title_suffix variable, not in $title_prefix. Just checked twice in my theme.
    – nerdoc
    Apr 1, 2016 at 4:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.