0

I am working on a website which has pages with dynamic google maps, which has made it necessary for me to make use of custom page templates. I ran into a issue earlier today and been trying to find a way around it for hours now:

I have two pages that I need to create templates for(lets call them /dash_a and /dash_b). I created a twig template saved as page--dash_a.html.twig which loads correctly when I navigate to the page on the website. Now I created the page--dash_b.html.twig but it doesn't load the template on this page surprisingly. It actually uses the page.html.twig template. I have tried the following:

  • Cleared all caches numerous times
  • Deleted the page /dash_b and recreated it
  • Disable Caching on the website
  • copied the content of page--dash_a.html.twig into page--dash_b.html.twig, cleared cache and refreshed page just to be sure there is no error in my twig file.
  • Created another page /dash_c and created a corresponding page--dash_c.html.twig to see if it will work but that too didn't work.

None of these could resolve my issue. Please what else is there to do to resolve this issue as it has robbed me of a whole day's work already. Any help will be appreciated.

P.S.: I am very new to Drupal and this is my first website on the platform, but I have used DNN extensively in the past.

1

Can we start easy? I think 9 times out of 10 when my templates dont load it's due to file naming issues. Do the file names match what's in the database as your content type machine name?

One thing that has happened to me a couple times is I hit enter too soon when creating content in drupal. That ajax just needs a little time to catch up and fill in the machine name. Too soon and your dash_c page could actually be named dash_

Do you have devel enabled? Can you see the *FILE NAME SUGGESTIONS when you "view source" of your webpage?

  • Thanks Prestosaurus, you actually pointed me in the right direction. I looked at the FILE NAME SUGGESTIONS for the page and was able to get one that works. Now I use the html--node--[node_id].html.twig naming convention and it is automatically picked. – Adekunle Adeshipo Oct 13 '17 at 8:52

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.