1

i want to use another page.tpl.php file, if die fb parameter is set. The File is located in my theme folder and has the name "page-fb.tpl.php"

My Function in template.php

function THEMENAME_preprocess_page(&$vars) {
/** Facebook Output */
    if ( isset($_GET['fb']) && $_GET['fb'] == 1 ) {
        $vars['template_file'][] = 'page-fb';
    }
}

The function is called, but the new page-fb.tpl.php is not loaded. I'm doing all of this on Drupal 7.

Any advices?

2

Rename page-fb.tpl.php to page--fb.tpl.php and then modify your code to use $vars['theme_hook_suggestions'][] = 'page__fb'; instead of what you got currently. For further information you can check out the Drupal 7 Template Suggestions page.

1

Here you made a mistake!

$vars['template_file'][] = 'page-fb';

The above line should be like below.

$vars['template_files'][] = 'page-fb';
  • okay, but is not working either. i think i forgot to mention, it is on drupal 7. – jussi Feb 24 '12 at 9:46

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.