Search code examples
phpdrupal-7drupal-theming

Drupal 7 - How to override template for page like node/%/custompage


I have small question about overriding template for Specific page in Drupal like this "node/%/custompage". As we know for

node/% is : page--node.tlp.php 
node/%/edit : page--node--edit.tpl.php

How about a custom page (I created in my custom module) like this 
node/%/custompage
I tried : page--node--custompage.tpl.php

But it seem doesn't work. Thank.


Solution

  • You have to check "Drupal 7 Template (Theme Hook) Suggestions" page: https://www.drupal.org/node/1089656

    Furthermore you can add your own theme hook suggestions. You could implement something like that :

       /**
        * Implementation of hook_preprocess_HOOK().
        */
        function mymodule_preprocess_page(&$variables){
          if(arg(0) == 'node' && arg(2) != 'custompage')
            $variables['theme_hook_suggestions'][] = 'page__custompage';
        }