custom page.tpl.php for a drupal view

Antonio Lopes picture Antonio Lopes · Dec 2, 2010 · Viewed 33.6k times · Source

How can I create a custom page.tpl.php for a specific view?

I'm not talking about styling the view itself, just the page where that view gets rendered.

Thank you.

@Keith Morgan - It's page.

Answer

Amir picture Amir · Jun 19, 2012

Per Allartk's solution
In Drupal 7 template.php:

function <theme>_preprocess_page(&$variables) {
    if (($views_page = views_get_page_view()) && $views_page->name === "galleries") {
      $variables['theme_hook_suggestions'][] = 'page__views__galleries';
    }
}

Then in your theme directory, create the page--views--galleries.tpl.php file. Clear drupal cache and template should work. I used 'galleries' as and example views name.