Getting a themed views title within a style tpl file

Profile picture for user Phil Frilling
By Phil Frilling, 6 September, 2012
I ran into an issue today where I needed to get a themed views title from within a views row style template file (tpl). I tried using drupal_get_title() and menu_get_item() but the title elements were all blank for these. Next I inspected the $views object looking for the themed title but it was not listed. Finally, I discovered within $views->build_info the title and substitutions variables.
    [ title ] => My Views Title - %1
    [ substitutions ] => Array
        (
            [ %1 ] => My Views Substitution
            [ !1 ] => My Views Argument from the URL
        )
After that, getting the themed title was easy using the t() function.

$title = t($view->build_info['title'], $view->build_info['substitutions']);