Pages not inheriting Drupal content
If I change /templates/layout/page.html.twig from:
{% include "@pages/_page.twig" %}
... to ...
{% include "@pages/article/article.twig" %}
... my site header and footer do not load their Drupal content. Everything looks fine in Pattern-Lab, but not in Drupal.
What am I missing? Thanks!
That would depend on the content of your article.twig file. Without knowing what's in it, there's no way to tell what you're missing. Can you post that here?
Sorry ... I haven't changed it from what was included with Emulsify ...
https://github.com/fourkitchens/emulsify/blob/develop/components/_patterns/05-pages/article/article.twig
Okay, the article.twig file doesn't have
{% block page_header %}
{% if page.header %}
{{ page.header }}
{% endif %}
{% endblock %}
(Or page_system or page_footer) so it won't show the drupal header.
If you {{ kint() }} the page in Drupal, you'll see page.header. That's where the Drupal header lives, so it has to be in the template if you want it to show
I guess perhaps another question would be ... since the included 05-pages/article/article.twig and 05-pages/home/home.twig use embed are we even supposed to use those in Drupal? Should I instead be modifying/copying/extending the 04-templates/_default.twig in my custom page.html.twig files? Are the article and home examples more for demoing those templates populated inside pattern-lab?
That is correct. The 05-pages in Pattern Lab are strictly for demoing what "built-out" pages could look like - usually with content entered directly in the Twig file. (They're also very useful for visual regression testing.)
All of the Drupal page-level templates should include or embed a file from the 04-templates directory.
I just looked and realized that's not how Emulsify is out of the box, but in my projects, the page.twig file is in 04-templates and I don't even have the html.twig file because I didn't need to override the one from stable.
That's a practice I've settled on after implementing this on a bunch of sites. We should probably update stock emulsify to reflect that as well, but you know... time... 😄
Thanks! Is your page file still essentially ...
https://github.com/fourkitchens/emulsify/blob/develop/components/_patterns/05-pages/_page.twig
... or some customized version of that?
I have need in a certain section of my project to modify that template, so I'm going to create a separate template for that.
And yeah ... fully understand the time issue. I've enjoyed working with Emulsify thus far and this series ...
https://www.fourkitchens.com/blog/development/introducing-emulsify-part-3-drupal-integration/
... has been helpful ... it's just this last hump to the top level of pages in Drupal that is tripping me up at the moment. Maybe part 4 of that series? :-)