0

I have 3 .tpl files, how can i call these tpl files by using function arg(). actually i want to show 3 different .tpl files to user when he request from a dropdown options.

The detail description is i want to create a page which render list of nodes in a page but i like to give option to user that weather he wants all the node in single column layout or 2 column layout or 3 column layout. For these layout i'm creating 3 different .tpl files so now i want to call them on the request of dropdown list.

2
  • Well, in simple way you can use views + quicktab module. Feb 20, 2015 at 7:28
  • i want to do it custom Feb 20, 2015 at 7:48

2 Answers 2

0

Considering that you want tpl for page, continuing to the answer https://drupal.stackexchange.com/a/149899/39999, you can create layout files as follow:

In template.php add following function and replace with your theme name:

function <THEME>_preprocess_page(&$vars){    
    if(isset($_SESSION['selected_layout']) && !empty($_SESSION['selected_layout']) && $_SESSION['selected_layout'] != 'select'){ 
        $vars['theme_hook_suggestions'][] = 'page__'.$_SESSION['selected_layout']; //setting a new page template
    }
}

Then create following template files:

  1. page--layout-1.tpl.php
  2. page--layout-2.tpl.php
  3. page--layout-3.tpl.php
0

If I understand it correctly you are looking for a way to render .tpl.php files on certain paths, this article explains how to do it.

In the article they define only one path and show you how to make sure a .tpl.php is rendered. You can easily adjust the code to make it work with 3 different paths and 3 different tpl.php files.

Hope this helps!

1
  • its not helping me please share some more info Feb 20, 2015 at 9:13

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.