Hello, I have theme debug set on my dev site, and I can see that these theme_suggestions should be available:

<!-- THEME DEBUG -->
<!-- CALL: theme('node__page__full') -->
<!-- FILE NAME SUGGESTIONS:
   * node--page--full.tpl.php
   x node--page.tpl.php
   * node--23.tpl.php
   * node.tpl.php
-->

I also have a file named `node--23.tpl.php` present in my custom theme directory. However, nothing I seem to do will select that template for use. The x never moves next to the file name in the view-source and the template is not loaded.

I have cleared the caches numerous times. I even truncated the cache table in the database. Nothing makes it work.

What else can I try? Thanks for any help.

Comments

It does work for me (just tested on a fresh install). This sounds silly but make sure your custom theme is enabled and set as default. Also make sure the template has a similar format as the one in the node module (core/modules/node/templates/node.tpl.php). Not sure if that is stopping this from working, but maybe.

Thanks for your response. My custom theme is enabled and default. Also it will not select node--23.tpl.php even if that is an exact copy of the core node.tpl.php with no changes at all.

I thought it could be my theme, so I disabled it and loaded the site in core's `basis` theme but that didn't help.

I thought it could be my custom layout so I changed the layout to core's `boxton` but that didn't help.

When I try to force it in template.php using

$vars['theme_hook_suggestions'][] = 'node__' . $node->nid;

in hook_preprocess_node() that also did nothing.

Anyway, I'm moving on to other issues on my site but if you can think of anything else I could try, please let me know.

 

Is the tpl.php file in a templates folder inside your theme folder?

I would also suggest creating fresh test site and put your theme there. Then create a dummy page and attempt your template override.

Yes, the tpl.php is in the right place.

I have just tried it with a fresh install of backdrop 1.27 and it works. So it seems I have to track down the problem somehow in my theme.

If I ever manage to solve it, I will post back here in case some one else has this problem.

I'm 99% sure that you'll have checked this but the node in question is definitely node id 23 isn't it?  You can double check by hovering over the "Edit" link in the tabs which would show https://yoursite.com/node/23/edit

Yes, it is definitely node 23.

Also, I just tried copying my custom theme to the new test site, and there the node tpl selection works, so I think I can eliminate my custom theme as the problem.

If you can install "Enabled Modules Report Recipe" (Machine name (for if you use bee/drush to install): enabled_modules_report_recipe) in the module installer this will give you a new report. See the project page above for details.

If you paste the report here, it may give a clue as to whether a contrib module we haven't thought of yet could be causing this.

I'm not sure what timezone you're in, but there is an Office Hours session later today (and each week on Wednesday) - 2024-01-17 19:00 - 21:00 GMT/UTC so if we haven't managed to figure it out you could drop in then, share your screen and someone can help you figure it out. See https://backdropcms.org/news/events for the latest events.

I have enabled enabled_modules_report_recipe but it outputs a report with nothing listed, regardless of whether I choose 'Limit to' with core or contrib, the output is nothing.

Anyway, I have had to move on with my work and solved it with an if-else-endif put directly into `node.tpl.php`. It's a bit ugly, and not really how I want to do it, but it works.

Thanks for your input.