Skip to content
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

Add a view display extender for the localgov_page_header for the lede #257

Open
wants to merge 8 commits into
base: 2.x
Choose a base branch
from

Conversation

andybroomfield
Copy link
Contributor

@andybroomfield andybroomfield commented Nov 13, 2024

Fix #127

What does this change?

Adds a setting to views that allows for a page header category, with the option
to set a custom lede inside the view, which will then be used by the
page header block.

How to test

  1. Enable the new page header display extender on /admin/structure/views/settings/advanced (should we enable this by default?)
  2. Create a new view with a page display.
  3. There should be a new page header section in the center of the views configuration.
  4. Edit that and add some summary text, you should also be able to use tokens from the view.
  5. View the views page, and the page header should also display the entered summary as the lede (part of the page header block).

How can we measure success?

Now possible for site builders to add subtitles to views.

Have we considered potential risks?

May conflict with others who have added their own extension to get a subtitle on the view.

Images

Screenshot 2024-11-13 at 9 47 10 am Screenshot 2024-11-13 at 9 52 19 am Screenshot 2024-11-13 at 9 52 23 am

Accessibility

@andybroomfield andybroomfield force-pushed the feature/2.x-127-page-header-views-display-extender branch 2 times, most recently from d02dade to 6f3421c Compare November 13, 2024 09:55
Fix #127

Adds a setting to views that allows for a page header category, with the option
to set a custom lede inside the view, which will then be used by the
page header block.
@andybroomfield andybroomfield force-pushed the feature/2.x-127-page-header-views-display-extender branch from 6f3421c to 5baf187 Compare November 13, 2024 15:16
@finnlewis
Copy link
Member

@Adnan-cds can see this will be potentially useful!

…yEvent

Since a viewExecutable is not a child of EntityInterface, provide seperate
$view property and set that when viewing a view page from the pageHeaderBlock.
@andybroomfield andybroomfield force-pushed the feature/2.x-127-page-header-views-display-extender branch from 161dbe8 to c9c7ad9 Compare November 19, 2024 21:39
@Adnan-cds
Copy link
Contributor

It works! Thanks Andy :)

The code looks okay at first glance. I would suggest that Steve @stephen-cox does a thorough review.

@finnlewis finnlewis requested a review from ekes December 3, 2024 11:23
@andybroomfield andybroomfield marked this pull request as ready for review December 3, 2024 11:54
@finnlewis
Copy link
Member

Some questions from Merge Tuesday:

  1. Do we want to enable this by default?
  2. How do we enable this by default? (Follow how MetaTag does this?)
  3. Code review: happy with the approach?

Copy link
Member

@stephen-cox stephen-cox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with this approach. One small nitpick with a type hint that's wrong and can probably be removed.

This does add a hard dependency between Core and Views. I don't have a problem with this as I can't think of an LGD site that wouldn't use Views, but we should add the dependency in the info.yml file.

I think it would also be good to enable this by default and maybe add an update hook to enable it for others. The test already includes the code on how to do this.

$config = \Drupal::service('config.factory')->getEditable('views.settings');
$display_extenders = $config->get('display_extenders') ?: [];
$display_extenders[] = 'localgov_page_header_display_extender';
$config->set('display_extenders', $display_extenders);
$config->save();

* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
/** @var \Drupal\metatag_views\Plugin\views\display_extender\MetatagDisplayExtender */
Copy link
Member

@stephen-cox stephen-cox Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type hint references the Metatag display extender and isn't needed here anyway

@stephen-cox
Copy link
Member

@stephen-cox Will test the update hook and merge if okay

@ekes ekes self-assigned this Jan 14, 2025
@andybroomfield
Copy link
Contributor Author

Discussed on MT on 28/1/2025: We'd like to get this reviewed soon. @ekes @stephen-cox please.

@stephen-cox stephen-cox self-requested a review January 30, 2025 14:47
Copy link
Member

@stephen-cox stephen-cox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good to me 👍

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

Successfully merging this pull request may close these issues.

How to add a lede (subtitle) to a view?
5 participants