0

I have made two pages, one for my sites Terms of Service and a second for a secondary add content page. I made both in views with a custom text field. I would like to have a custom page.tpl.php file for these pages so they can better match my theme. How would I do this? Also, If anyone has a better way for me to make a TOS page, I would appreciate the insight. I will be making a page describing my privacy policy as well as few other things and I want to make sure Im doing this in the most efficient way. Thanks.

  • 2
    Why did you choose to make these pages with Views? Views is a tool for building database queries and it sounds like these pages are just static text/content. Why would you not just create a "page" node? I think some more detail is needed to understand your overall needs/goal in order to help you with this issue. – sheena_d Jan 13 '12 at 15:44
  • You're right, I removed the page content type early on in my sites development. I have no I idea why this didn't occur to me :p. thanks. – oobie11 Jan 14 '12 at 4:46
3

I agree with sheena_d's advice above -- it sounds like what you are trying to accomplish could much more easily be accomplished by using simple pages. That said, here is one way you could do this using views overrides in your template.php theme file.

What you're after is this command:

$variables['template_files'][] = "your-new-view.page.tpl.php";

but you need to get Drupal to hook into this somehow. One way to do this is with a views preprocess function, added to your template.php file:

function <your-theme-name>_preprocess_views_view__<your-view-name>(&$variables) {
    $variables['template_files'][] = "your-new-view.page.tpl.php";
}

You would need to replicate this function for however many views you want to override the page.tpl.php file for.

  • Awesome, thank you! If you read my comment above you'll see I was being a moron, but your explanation is very valuable. Thanks. – oobie11 Jan 14 '12 at 4:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.