0

I have done some research and everything I see to create a node specific template says to name the template file, for example, page--node--676.tpl.php

However when I clear the cache and load the file it still shows the old template. What could I be missing?

  • In what folder did you put page--node--676.tpl.php? – No Sssweat May 3 '18 at 1:20
  • sites/all/themes/mytheme/templates – ummerme May 3 '18 at 15:42
2

If you haven't already done so, I'd recommend enabling theme debugging feature of Drupal 7.

In the settings.php file, or preferably in settings.local.php file if you have one, add the following line, and clear the cache once more.

$conf['theme_debug'] = TRUE;

When debugging is enabled:
- The markup of each template is surrounded by HTML comments that contain theming information, such as template file name suggestions.
- Note that this debugging markup will cause automated tests that directly check rendered HTML to fail.

For more information about debugging theme templates, see https://www.drupal.org/node/223440#theme-debug.

Not recommended in production environments.

This should give you the available template name suggestions in the generated HTML.

  • debugging returned the suggested page--node--676.tpl.php sites/all/themes/mytheme/templates and that is is loading page.tpl.php – ummerme May 3 '18 at 15:43
  • Are you saying when you view /node/676 your theme still uses sites/all/themes/mytheme/templates/page.tpl.php instead? Or page.tpl.php from another theme? Do you use a base theme? – osman May 3 '18 at 17:04
  • Yes, when I view /node/676 the theme is still using sites/all/themes/mytheme/template/page.tpl.php instead of page--node--676.tpl.php the only other template source I can see is modules/system/html.tpl.php – ummerme May 3 '18 at 17:15
  • That’s odd. Even if you have a preprocess function in your theme overwriting suggested template names, debugging would show those in results too. Any chance the file name has invisible characters in it? Try copying the suggested name and renaming your template file with that. – osman May 3 '18 at 17:51
  • Not sure what I did, but it started working. Thanks for the help. – ummerme May 3 '18 at 20:10

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.