I'm building a block in Views where different brands show off their respective products, now I'm wondering if it's possible to pass a field value to the title.

I know that %1 results in displaying the title

I've tried searching for a solution, but fail to find one as I'm not that familiar with the terminologies of Drupal (as in I don't really know what specifics to search for). This might be super simple, but I can't seem to find the answer and if possible it could become pretty useful in the future.

1 Answer 1


Changing a View's title is a theming issue. Have a look at Views: how to programmatically change Views title?. The accepted answer is almost what you need. Add the function to your theme's template.php file (or your custom module if you don't have a custom theme yet).

The rest is simply coding. Store the field that you need as a variable $my_field and adapt the code from the referenced answer as follows:

function MY_THEME_views_pre_render(&$view) {
  if ($view->name == 'YOUR_VIEW_NAME') {
    \\ Store your field: $my_field = ...
    $view->build_info['title'] = "YOUR TITLE" . $my_field;

You can use the Devel module to inspect $view in order to easily find the correct code for $my_field.

Your Answer

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

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