I am new to Drupal and am working on a partially complete site. There's a .tpl file I wish to duplicate and alter and have only be used with a certain Panel Page type ('Product Page').

I've read Drupal's documentation about template suggestions, but am not sure what to actually do.

I've placed the following in my template.php file:

function mytheme_preprocess_node(&$variables) {
  if ($variables['???']) {
    $variables['theme_hook_suggestions'] = 'new_tpl_file';

But I've got no idea what to put in $variables[''] so that the suggestion appears on my pages. I know my Panels page is called 'Product Pages' but that's it. Is there a machine name for that I can use as a variable? Would it work if it was something like:

      if ($variables['product_pages']) {

Does anyone know of a tutorial or guide out there? Im pretty lost here. Any help is appreciated!


If you are trying to override panel page template then I am afraid you are using the wrong hook, hook_preprocess_node works for node pages only.

However panel page goes through hook_preprocess_page, so you can add custom template suggestion in following way.

 * Implements template_preprocess_page().
 function MODULEORTHEMENAME_preprocess_page(&$variables) {
    if (module_exists('page_manager') && count(page_manager_get_current_page())) {
        $variables['theme_hook_suggestions'][] = 'custom__panel';

Then create custom-panel.tpl.php

Reference: page.tpl.php override for Panels Pages?

  • Thanks, this seems to be in the right direction, but no luck here. I still dont see the template suggestions. – MeltingDog Feb 13 '17 at 7:17

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.