First of all, this theme is awesome! I like it a lot and will be using it for my own company website.

I was about to create a sub-theme of architect such that I could tweak a few minor things and I ran into a problem. Some of you twig files are using {% include directory ~ '/templates/.....' %} stuff which is failing with a sub theme. It appears that the variable directory is set to the path of my sub theme and then it doesn't find the required files.

I was looking into other twig files in Drupal core and it seems that they are working with something called namespaces. So maybe that's a better way of doing this.

CommentFileSizeAuthor
#2 mytheme.zip3.23 KBisaachorton
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jurgenhaas created an issue. See original summary.

isaachorton’s picture

FileSize
3.23 KB

Thanks a lot for the feedback. These are the kind of issues that are sometime difficult to uncover. Its funny Im just about to go through all the Uikitty themes and build out a sub-theming explanation for each one which would have led me down the same road as you, so thanks for reporting this issue!

I was able to verify the bug in my installation of Architect, so you are indeed correct. What's weird is this is the recommended path for code inclusion so I think this is a Drupal bug and I will report it. https://www.drupal.org/docs/8/theming-drupal-8/including-part-template

My quick solution and what Im going to recommend for the installation path and for my example sub themes is to simply copy the /templates/includes folder from the Architect theme to your subtheme. This will fix the unexpected server error at least in my tests. I will look into the namespace thing you mentioned but I havent heard yet any mention of that anywhere, can you point me in the direction of what you are referring to?

I attached a sample sub theme I quickly threw up called "mytheme". Its a bare bones example of how to properly start a sub-theme for the Architect. The only variation beyond a blank theme is to include the same regions as the architect theme in the info.yml file and also copying in the includes directory. Beyond that, its totally blank.

Thanks again for the issue report and the Kudos are always very appreciated!!

jurgenhaas’s picture

Thanks @isaachorton for picking this up and it's indeed interesting to see the documentation you've linked to. That looks certainly like a bug and if you do a search in all files of Drupal cor for {% include you won't find a single usage of the directory keyword anywhere. What you can find instead is e.g. {% include '@views/views-view-field.html.twig' %} where @view is what I referred to as a namespace. Found another one like {% include "@twig_namespace_b/test.html.twig" %} which actually lead me to that thinking. The first example could also have been a project name, but the second doesn't.

Your workaround with copying the includes directory is an option, I've resolved it with a symbolic link for now.

Hope you can find a solution for better resolution.

isaachorton’s picture

Wow! this is great!!!! I had to track down what was going on which is not surprising! Alas there is an already registered twig namespace for twig templates in each theme.

I fixed the files by changing the twig includes to use the registered theme namespace like this:

{% include '@architect/includes/header.html.twig' %}

Im updating the architect theme now and will tag a new release with the changes once Ive verified it's working as expected across the board.

@jurgenhaas Thanks a ton for reporting this issue and helping me find the solution!!! You're the man!

isaachorton’s picture

Assigned: Unassigned » isaachorton
Category: Support request » Bug report
Priority: Normal » Critical
Status: Active » Fixed

fixed in the newest release.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.