The way that we're implementing the layout CSS class is a bit confusing. We can make it more clear.
1) We can remove the node--article--full.html.twig file, and add the layout--content-narrow class via preprocess.
2) We need to remove the layout variable from node--teaser.html.twig.
Original summary
Here is the content of node--article--full.html.twig
;
{% include '@olivero/node.html.twig' with
{
'layout': 'content-narrow',
}
%}
The layout
variable is concatenated by after in node.html.twig
like this:
{% set layout = layout ? 'layout--' ~ layout|clean_class %}
Question 1: Why over-complicate with the concatenation? The themer needs to know that he/she have to use part of the class name (without the starting layout--
)... a more simple way would be 'layout': 'layout--content-narrow',
Question 2: Why using an include if it is used only once? More over, in the case of a subtheme @olivero
could lead to an issue for someone who have edited node.html.twig
[I am completely open to hear a good reason for that...]
Question 3: why using the layout
variable in node--teaser.html.twig
as I don't see where it is populated?... But maybe I missed something.
Comment | File | Size | Author |
---|---|---|---|
#15 | 3142857-15.patch | 1.35 KB | mherchel |
#12 | 3142857-12.patch | 1.17 KB | mherchel |
#10 | 3142857-9.patch | 1.18 KB | sulfikar_s |
#10 | after-patch-apply.png | 23.34 KB | sulfikar_s |
#8 | 3142857-8.patch | 1.04 KB | Abhijith S |
Comments
Comment #2
DuneBLComment #3
steinmb CreditAttribution: steinmb as a volunteer commentedI had a look at the code but I found it a little confusing too. Perhaps @mherchel know? Introduces in #3118071: Theme Content/Article Listing - Node Teaser
Comment #4
mherchelThe article node content type has a narrower layout than other content types (see designs at https://www.figma.com/file/x5zBLbvoW1jsvyAOt4Gp9I/Olivero-Theme---Public...).
1) I personally don't think it's too complicated, but I can see your point.
2) This is a good point. We could easily add this class via preprocess instead.
3) I'm not sure this variable is being used. This may need to be removed.
Comment #5
mherchelComment #6
kostyashupenkonode-teaser.html.twig was updated here already
so i have fixed only first point
Comment #7
anmolgoyal74 CreditAttribution: anmolgoyal74 at OpenSense Labs for DrupalFit commentedRemove the additonal space and add the comment.
Comment #8
Abhijith S CreditAttribution: Abhijith S as a volunteer and at Zyxware Technologies commentedPatch #6 is working fine.Since #7 is failed ,I've removed additional white-space from #6 . Please check it
Comment #9
mherchelPatch doesn't apply
Comment #10
sulfikar_s CreditAttribution: sulfikar_s at Zyxware Technologies commentedHello, the patch in #8 doesn't apply as said in #9.
I have re-rolled the patch in #8.
Please review.
Edit: Sorry for the patch number, I've mistakenly added it as '9'. It is actually '10'
Comment #11
sulfikar_s CreditAttribution: sulfikar_s at Zyxware Technologies commentedComment #12
mherchelWe want to use strict type checking here (=== instead of ==)
You're removing the content, but leaving the template. This means that the article will not show at all. We need to remove the entire template file.
Attaching updated patch.
Comment #13
proeungA bit of nitpicking, but I think it'll be helpful to include a comment in this preprocess function that lets folks know that this string is being used in the node template where we're defining the layout class.
'layout--' ~ layout|clean_class
Comment #14
proeungAdjust the title of this issue to include just the
node--article--full
node template.Comment #15
mherchelGood point. Updated patch attached!
Comment #16
proeung@mherchel Looks great! Thanks for adding this comment!
Comment #17
alexpottBackported to 9.1.x as this is for an experimental theme.
Committed and pushed a997779d33 to 9.2.x and 9bc878583d to 9.1.x. Thanks!