Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Pages not inheriting Drupal content #331

Open
dchaffin opened this issue Mar 19, 2019 · 6 comments
Open

Pages not inheriting Drupal content #331

dchaffin opened this issue Mar 19, 2019 · 6 comments

Comments

@dchaffin
Copy link

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!

@ModulesUnraveled
Copy link
Contributor

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?

@dchaffin
Copy link
Author

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

@ModulesUnraveled
Copy link
Contributor

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

@dchaffin
Copy link
Author

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?

@ModulesUnraveled
Copy link
Contributor

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... 😄

@dchaffin
Copy link
Author

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? :-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants