-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
122 consider stacked h1 pattern for guides #133
base: 2.x
Are you sure you want to change the base?
Conversation
- We provide both the current node data AND overview node data to templates so they can alter the current default while preserving the current output in every case. - Re: 122_consider_stacked_h1_pattern_for_guides
- Re: 122_consider_stacked_h1_pattern_for_guides
- Re: 122_consider_stacked_h1_pattern_for_guides
- Re: 122_consider_stacked_h1_pattern_for_guides
- "Legacy" heading uses the exact values the current rendering uses. - Non "legacy" heading uses templates from the module following the pattern <h1>{{ guide_page_title</h1><p>{{ overview_page_title }}</p>. - Re: 122_consider_stacked_h1_pattern_for_guides
- Re: 122_consider_stacked_h1_pattern_for_guides
- Re: 122_consider_stacked_h1_pattern_for_guides
- Retains current rendering, but anticipates that the {{ lede }} render array could have a different structure. - A forthcoming change to localgovdrupal/localgov_guides may require this. - See: localgovdrupal/localgov_guides#133 - Re: 491-localgov_base-directly-access-value-property-of-lede-in-localgov-page-header-blockhtmltwig
'#tag' => 'p', | ||
'#value' => $overview->get('body')->summary, | ||
]); | ||
if ($this->settings->get('legacy_header')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a site hasn't explicity set to use the legacy header, this will automatically opt them into the new style until they save the config form. Maybe consider reversing the check to see if they want new style headers? Or make sure to include an update hook for existing sites to set this as legacy header. Note the settings form below does assume legacy header as default, but it won't apply until its saved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I missed that (saved the form before ever testing). I've taken your first suggestion to require the checkbox to be set to use the 'modern' rendering. That means the default, unsaved state uses the existing rendering (since it defaults to FALSE
).
* {@inheritdoc} | ||
*/ | ||
public function __construct($config_factory) { | ||
$this->settings = $config_factory->get('localgov_guides.settings'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting the settings from the config factory in the constructor is considered an anit-pattern. Instead get the config factory in the constructor and then get the settings when needed. We ran into an interesting issue with this at BHCC with a contrib module causing some strange side effects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to know. Fixed.
- The checkbox now sets 'modern' rendering. This allows a never-saved form to default to FALSE and the 'legacy' rendering. - See #133 (review) - Re: 122_consider_stacked_h1_pattern_for_guides
- The form changed the config setting key from legacy_header to modern_header and now defaults to FALSE, so the check here needs to invert the logic and change the name. - See #133 (review) - Re: 122_consider_stacked_h1_pattern_for_guides
- See #133 (review) - Re: 122_consider_stacked_h1_pattern_for_guides
- Re: 122_consider_stacked_h1_pattern_for_guides
localgov_guides.settings: | ||
title: Localgov Guides Settings | ||
description: Configure the localgov_guides module | ||
parent: system.admin_config_system |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Content authoring would be a better parent? Would be interested in others opinions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me too. I couldn't figure if there was a standard localgovdrupal approach for these sorts of settings.
Just checking something, appreciate this is still being worked on. I notice that it's not wrapping everything in the h1, insead setting the title of the guide overview as a lede. Looking at the h1 pattern on the NHS site example, it the Guide page title and Guide overview are wrapped in a single h1. It looks like we should be able to achive the same effect by setting this to the setTitle (and passing a render array for the subtitle, or adding subtitle support to the core page header block) and either setLede to blank or allow an option to allow the page summary to be displayed as normal. ![]() ![]() |
We can't influence that from here. <div class="lgd-page-title-block">
<h1 class="lgd-page-title-block__title">Title content</h1>
<p class="lgd-page-title-block__subheader">Lede content.</p>
</div> ...while <div class="clear-both headers key">
<h1 class="header">Title content</h1>
<div class="subheader"><p>Lede content</p></div>
</div> These are close to the whatwg recommendation for heading/subheading markup (though that surrounding
This is what I was getting at in #122 when I said "...I think we have a workable solution, assuming that the place to solve the problem is in the individual modules that consume the page header block, and not at the module that provides it." Given the Added: sorry, I didn't answer this question:
Strictly speaking, there isn't. But #122, and the fact that This change doesn't require |
Thanks for the explination @ctorgalson. @finnlewis I notice that localgov_publications uses a completly sepearte block and template, not the localgov_core page header block. |
Thanks for all the thought on this. Discussing in Merge Monday meeting, I think I'd like to have a think about how we might standardise this across all relevant content types. @markconroy have you had a chance to think about this? We also need to fix the tests. |
I think this approach looks really good (along with the corresponding PR in I'm not overly convinced about having a checkbox for "use legacy header" vs "use modern header". That looks like we might in future be adding even more checkboxes for things like this such as "use even more modern header", but am not sure how we get around this issue either without breaking changes. Perhaps we can have this change only for current sites and hide that checkbox on new installs? But for now, I'm happy with this. |
@markconroy Arguing against myself, the more standardis-y approach might be to do this (the Twig template) in the original block in
It's only a way to expose a boolean config entry. For now, it maintains the status quo, but in a major version release, an update hook could reverse the default setting so that new installs would get the 'modern' rendering. |
@finnlewis @andybroomfield Any further thoughts about this approach? |
I've put my proposal as a draft PR localgovdrupal/localgov_core#193. |
I'm happy to see that (IMO the best place to address this is in the block-provider |
If there is a need to get this in soon for guides we could go with the solution here and then develop the common solution in Localgov_core. Since to use the solution in core this would need a new release anyway which could then require a minimum version of localgov_core to work with once its done. either way localgov_base needs it's fix applied. |
Sorry @ctorgalson - this seems to have lost momentum and we have some conflicts. Are we still looking to fix this and get this merged? |
This change adds a new optional way to render the title info of Guide Pages (leaving Guide Overviews untouched). The new method renders something like this:
Code-wise, what we're doing is this:
templates/
and tohook_theme()
,Note that
localgov_base
doesn't properly render the 'new' version because it directly accesseslede['#value']
instead of just printinglede
. This means that, for the moment, this change requires a project using it to overridelocalgov_base/templates/block/localgov-page-header-block.html.twig
.If
localgov_base
printed the variable like this instead, it'd solve the issue--I'll propose it on the relevant repo: