1

Our site uses taxanomy to maintain a blog page. And for now we use views to render the contents. Now we are planning to get rid of views and use templates. What we need is to have custom tpl.php only for request containing vocabulary. So for any request to my site of a pattern path/*,

  1. I need my custom tpl.php to be used only when the path is valid vocabulary.
  2. Let the default flow get executed when the path is not a valid vocabulary.

What would be right way to handle this?

0

In views use TID converted to Name filter then use TID in url as a parameter and when the url is hit check the tid is valid or not and write behavior accordingly.

|improve this answer|||||
  • sorry.. forgot to add that we are planning to get rid of views. Updated the question now. – Kannan Ramamoorthy Sep 22 '15 at 10:00
0

You can use template_preprocess_page() to check the specific path and add your custom template.

function template_preprocess_page(&$vars, $hook) {
  $path = current_path();
  if ($path == 'your_path') {  
    $vars['theme_hook_suggestions'][] = 'page__custom';
  }
}

So your template file should have the name page--custom.tpl.php

|improve this answer|||||

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.