There's a view page which takes in taxonomy terms to display related content topic/Easter, where Easter is the term. Now in this example, I would like to create a separate TPL for that page topic/Easter. Is that possible?

  • What version of Drupal? – Kevin Apr 4 '17 at 18:10
  • Drupal 7. Apologies for not including that. I'll update my question. – user1470118 Apr 4 '17 at 18:15

You can use Taxonomy Views Integrator module. Create separate views for this taxonomy term page and set it. And You can create separate template for this views.

Or You can use hook_preprocess_views_view for creating views template for custom view and custom view display. For ex.

     function THEMENAME_preprocess_views_view(&$variables) {
      $view = $variables['view'];
      if($view->name == 'your_view_name' && $view->current_display == 'main_page')
        $variables['theme_hook_suggestions'][] = 'views_view__viewname';

Your template will be views-view--viewname.tpl.php in this case

  • I don't see that as being something I'm looking for. All that's doing is selecting a view on the term categories. I need to be able to use a TPL. – user1470118 Apr 4 '17 at 19:42

My solution does include Taxonomy Views Integrator module. You will need to start off with creating a view to replace default taxonomy term view. Once that's done, you can edit view (Other section > Theme) and see what templates are being used. You can then make a copy of those templates and make changes based on your requirements. See screenshots below.

Section Theme Selection

Please ensure that you select template specific to view otherwise the changes will be applied to all the views. In my example (Screenshot), I will create a view template like views-view--articles-admin--page.tpl.php to specifically target this view. If I make changes to views-view.tpl.php template this change will be applied to all views.

Let me know how you go.

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.