I'm trying to alter the view page title by using the template_views_pre_render function inside mytemplate.theme file. It works fine, I'm able to modify its title this way:

$view->build_info['title'] = ...

My issue now is that I need to restrict this action to only one specific view, so I simply need to check the view id. I tried with if ($view->id == 'my_view_id') {...} but I realized I can't access the $view values because they are protected. How can I implement this control here?

1 Answer 1


To access the value of the view object you can use the method get():


Or if the object provides a special method for the id, which is the case with the view object:

  • It works! Thanks a lot, this is exactly what I was trying to understand.
    – Gabriele
    Feb 19, 2016 at 10:52

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.