I override template in my custom theme na (templates/block--[module]--[delta].tpl.php) and I would like to include other template (from the same directory) into this. Can I do it and how?

Directory structure


block--views--front-page-block-1.tpl.php (concept what I want to do):

     /* init $path (or maybe it is not needed) */
     include($path . 'example-file-template.tpl.php');
  • include it, maybe? What have you tried? What is your problem, exactly? – Mołot Sep 9 '14 at 11:10
  • Please, take a look on my edit @Mołot – kspacja Sep 9 '14 at 11:19
  • "or maybe it is not needed" - have you tried, with and without? If so, why "maybe"? If not - why not? it would take you a few minutes to try. Far less than asking a question here. – Mołot Sep 9 '14 at 11:22
  • It was only contept - I don't even know how to it. Normal include doesn't work. There is variable $path to highlight that maybe I need to create/generate path but I don't know how – kspacja Sep 9 '14 at 11:31
  • 3
    @kspacja drupal_get_path('theme', 'my_name_of_theme ') gets you what you need – Clive Sep 9 '14 at 11:36

You can get another drupal theme path with drupal_get_path('theme', 'theme_name'); and finally

     include(drupal_get_path('theme', 'theme_name').'/example-file-template.tpl.php');
  • also path_to_theme() works for the current theme, and is shorter. – Alfred Armstrong Sep 15 '14 at 8:46
  • @AlfredArmstrong yes, but he need to use the theme files in current theme .so need use path of not default theme . – Yuseferi Sep 15 '14 at 9:44

You can use path to theme (Uses the current allowed theme):


Or Drupal get the path (You can set the theme you want to use):

    include(drupal_get_path('theme', 'THEME_NAME').'/templates/TEMPLATE_NAME.tpl.php');

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.