How can I make a View use a different page template?
brianV - October 2, 2008 - 19:19
Hello.
On a Drupal 5.x site I am working on, I have a view which needs more space then the general content area allows, so I need to place it in a different page template.
Is there any way I can make a page-viewname.tpl.php which will work for this view, similar to how you can do it with nodes? (page-node-.tpl.php)
Thanks for any suggestions!

Path based page templates
I don't think you can in quite the way you describe, however look into how to make different page templates based on the URL Path alias, which should be able to do it... there's something in the Handbook about it. Alternately, at least consider whether CSS could accomplish this for you (it probably can, if you know how CSS works it shouldn't be too hard). Remember it's also possible to disable sidebar blocks at any given URL as well, so that could help make space. If you give all your pages a CSS ID based on the URL then you can do almost anything to various pages using just CSS. If you need to literally disable a few bits of HTML in certain cases, you may be better off to use a little PHP in a single page template (dealing with multiple page templates is a pain).
-- David
absolutecross.com
[new guide/lesson in progress: Creating a CCK and Views powered Drupal site - feedback welcome]
Same need, some solution
I'm not sure it really fits your requirements, but actually I want to control the page template being used by views when displaying as a page.
From what I found out, when executing the page level template, there is pretty much nothing that tells you that a view is being processed.
then I endend with a reverse test (I use zen classic sub theme):
<?php
function zen_classic_preprocess_page(&$vars) { // only executes at the page level
// making it easier to read with local variables
$node = $vars['node'];
$page = $vars['page'];
$is_front = $vars['is_front'];
if (is_null($node) && is_null($page) && !$is_front ) { // not a node, not a page, not the front page, but executing a page template : a view !?
// suggesting a template file for the page level
$vars['template_files'][]='page-YOURPAGETEMPLATEFORVIEWS' ;
}
}
?>
Which however isn't perfect since it means that all my views displaying as a page have the same page template
For the views theming itself, I'm about to look at Active Template
Views 2 (for D6 only) has a smarter approach
subscribe
subscribe
______________________________
next project convert this site to drupal -> http://www.oghnia.com
Just to kind of close this
Just to kind of close this off...
I ended up creating a node with the 'page' content type, then created a custom template for that page. I believe the title was something like page-253.tpl.php. In the custom template, I made it how I needed it, and then embedded the view using
$view = views_get_view('view-name');print views_build_view('embed', $view);
More info at http://drupal.org/node/99721
----
Brian Vuyk
Web Design, SEO and Applications Development
Long Sault, ON, Canada
Phone: 613-216-5161
brian@brianvuyk.com | http://www.brianvuyk.com