By msteudel on
I have a view called course_programs that when I view it with Themer Info I see that it is using page.tpl.php as its page template. How do I change or supercede that? e.g. page-views-view--VIEWNAME.tpl.php and I can control the entire page?
Thanks MS
Comments
Your view will have a path
Your view will have a path so you can use that. For example if your path was 'bike', you would use page-bike.tpl.php. If your path was 'bike/three_wheel' you could use page-bike-three_wheel.php.php.
That's what I thought
But for some reason it's not working. It works for other pages, but they aren't views, so I thought maybe it was something related to a view. Any thoughts on what to try? I've made sure to hit the "Scan Templates" button to rebuild the registry everytime I've made a change.
Visit Administer › Site
Visit Administer › Site configuration › Performance, click the "Clear cached data" button (toward the bottom).
Still not working, make sure you have the file name correct (yes, I have mistyped the name). Make sure the case matches and so does the punctuation. I have a bad habit of when the view has a underscore of using a dash in the file name. For example if the view path is some_view, the template file should be page-some_view.tpl.php.
Ok so looking at my view, and
Ok so looking at my view, and then clicking on the page section:
Path: programs/list
So my template should be:
page-programs-list.tpl.php (i cut and pasted from my filename)
Right? Then I cleared chache and rescanned my templates ... this is so bizare ...
Sorta tracked it down
Ok in my template file (based of zen) I have this function:
function passagesnw_preprocess_page(&$vars, $hook) {
//$vars['sample_variable'] = t('Lorem ipsum.');
if (module_exists('path')) {
$alias = drupal_get_path_alias(str_replace('/edit','',$_GET['q']));
if ($alias != $_GET['q']) {
$suggestions = array();
$template_filename = 'page';
foreach (explode('/', $alias) as $path_part) {
$template_filename = $template_filename . '-' . $path_part;
$suggestions[] = $template_filename;
}
}
$vars['template_files'] = $suggestions;
mail( 'msteudel@gmail.com', 'suggestions', $suggestions );
}
}
When I mail myself the $aliase and $_GET['q'] variable they are are the same
programs/list
programs/list
Looking at the code, it's ignoring not suggesting any template files because the alias and the $_GET['q'] are the same. If I print out the var variable the template_files is blank as well. If I take out the if statement it works. I wonder if I got this function somewhere else. It's not what is in the zen template.php file ... any ideas?
Try changing $suggestions =
Try changing
$suggestions = array();toto maintain any current suggestions (that code is meant to add suggestions if the page has an alias). As is this line
$vars['template_files'] = $suggestions;should be inside the 'if' statement. With it's current placement it removes all template suggestions in the case the path is not aliased ($alias == $_GET['q']).Great idea thanks
Great idea thanks