0
votes

I have a view called "video_by_category" with a path of "video/category/%" the % is looking for a taxonomy term. A term can be "car". I want to create a custom page template for this view similar to page.tpl.php. I made some theme suggestions like page-video-category, page-video_by_category.tpl.php, page-views-view-video-category.tpl.php, but nothing is working. How can this be done?

In my template.php I have this:

function theme428_preprocess_page(&$variables) {

  if ($variables['node']->type != "") {
    if (arg(0)=='node' && arg(2)!='edit') { // not for node edit forms
        if(arg(1)!=''){
            $arg1='-'.arg(1);
        }


        //$variables['template_files'][] = "page-node-" . $variables['node']->type.$arg1;
        $variables['template_files'][] = "page-node-" . $variables['node']->type;
    }


  }

    //print_r($variables['template_files']);
      $variables['scripts'] = drupal_get_js();  


  return $variables;

}

thanks

2

2 Answers

1
votes

Your best bet is to use the results of page_manager_get_current_page() in your preprocess to determine if you view is active. You can then use arg() to get the term (it may also be in the handler info). You can then either just tack on a new body class, or you can set your own template suggestion (http://drupal.org/node/223440), which you are doing already for something else.

Personally, I try to have a single page template for the whole site, and then do custom layouts with panels pages and custom panel layout templates. I find using views as pages more trouble than they are worth.

0
votes

Views 1 used to have an automatic creator for this, but 2 doesn't... See documentation