Problem/Motivation
For accessibility reasons, it is likely to have a different page title for different pages. Paginated Views provides an unique title for all the pages of the same View.
Proposed resolution
Allow to use the title area handler everywhere (see attached patch from @dawehner)
Overwrite the title of the views provided by the Core to append the page number to their title.
Remaining tasks
Discuss, patch, review, commit.
User interface changes
Views UI is going to allow to use its title handler everywhere.
API changes
None.
Data model changes
Some new settings in the View config entity.
Comment | File | Size | Author |
---|---|---|---|
#45 | 2509716-nr-bot.txt | 150 bytes | needs-review-queue-bot |
#26 | 2509716-tokens-in-page-title.patch | 2.42 KB | mikeker |
#26 | 2509716-tests-only.patch | 829 bytes | mikeker |
#25 | interdiff.txt | 460 bytes | Munavijayalakshmi |
#25 | 2509716-25.patch | 1.61 KB | Munavijayalakshmi |
Issue fork drupal-2509716
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #1
DuaelFrComment #2
DuaelFrComment #3
dawehnerTo be clear, if we allow the title area handle to be used everywhere, all this is already possible.
On the other hand I think maybe for the frontpage view we could set it by default, on the other hand I don't think we should assume anything the way how people build
their site, so the default for new views should not be filled with all kind of stuff.
Comment #4
DuaelFrUpdated IS after a discussion on IRC.
Comment #5
mgiffordThat's it? Will have to find time to test it out. What is the best way to test this?
Comment #6
DuaelFrNope, that's just a patch provided by @dawehner to allow to use the title handler everywhere.
We still have to alter the default views and to write some tests.
Comment #7
mgiffordOk. Think this is something we can do within 8.0?
Comment #8
dawehnerWell yes, default views could provide that, but at the same time, I don't think it would be a good idea to enforce it.
Comment #9
DuaelFrIt depends on the focus we want to have on accessibility.
The page title is always the first thing a screen/Braille reader reads so if that title does not change, the user have no clue about the fact that the content changed or not. If that user comes from an external link, the page number in the page title could be an interesting clue on how fresh the content he is watching is.
For aesthetic reasons, the first page should not have it title rewrited. That's why I wanted to use something more specific than the existing title rewriter that works with tokens. Plus, it should be more understandable for site builder to have a dedicated handler with a relevant name.
Comment #10
dawehnerWell, you could make an advanced option on the title area handler, which also allows you to set the title different for the first page, for example.
Comment #11
mgifford@dawehner - I don't see how appending the page number is anything but a best practice for everyone. Why wouldn't it be a good idea to know where you are midway in a view of 1000 pages?
It isn't how Google does it, but really can't see much argument opposed to it other than that.... Mind you Google has very mixed results on accessibility and don't think is striving for WCAG 2.0 AA.
I'm fine with adjusting the patch to see that this can be disabled through the UI and that the first page or initial text (can be customized). I think that the default should be to include the page number in the title though.
The closest I could find for pagination for this in WCAG is:
http://www.w3.org/TR/UNDERSTANDING-WCAG20/navigation-mechanisms-title.html
But this is a requirement for WCAG 2.0 A which is below our requirements. This might well be a bug rather than a feature. @DuaelFr thoughts on this?
Comment #12
DuaelFrThank you Mike for looking into the WCAG specs to find the closest reference and to keep that issue alive ;)
I don't know if we can categorize this as a bug. For me, a bug is when the software does not fulfill the functional promise. In this case, everything works the way it is expected to.
If the WCAG 2.0 is something Drupal wants to follow (and it should) and if this issue is a clear blocker, I suppose we could make it pass the beta evaluation, even without turning that issue into a bug report.
We might need a core maintainer opinion right now to avoid spending a lot of time on something that could be postponed unless @dawehner or another Views maintainer wants to judge.
Comment #13
mgiffordThe goal of Drupal 8 is to be WCAG 2.0 AA. If it isn't, it can be considered a bug. How important we prioritize that is another issue. Just because it's an accessibility bug doesn't mean that it is a blocker though.
I am a core maintainer, but certainly appreciate input from folks like @dawehner who know this module so much more.
Having a tolken like @DuaelFr described in #9 would be ideal. I've just thrown this together quickly with what I think we are looking for:
The pagination should be in the title by default but easily removed.
Comment #14
mikeker CreditAttribution: mikeker as a volunteer commentedInvestigating the idea of a
[page_number]
token for use in area handlers.Comment #15
mikeker CreditAttribution: mikeker as a volunteer commentedTurns out we already have
[view:current-page]
and[view:page-count]
tokens, though the page-count token is incorrect: #2572355: Some view tokens ([view:page-count] and [view:total-rows]) are incorrect.Now looking into what it takes to get those tokens to render for the title field.
Comment #16
mikeker CreditAttribution: mikeker as a volunteer commentedAttached patch allows global tokens in the display title.
Comment #17
mikeker CreditAttribution: mikeker as a volunteer commentedSelf review:
We're not passing a langcode in the $options argument to globalTokenReplace(). Is that bad? Or is that only to override the default langcode?
Would love to hear from i18n folks on this.
Can someone explain this to me? It came up in #4 so I left it in... But if it just allows the title handler to be used in other "area" spots (header, footer, etc.) that won't help us in this case because the view title is (somewhat oddly) rendered in the ViewExecutable object rather than the display handler and isn't an "area".
Comment #18
mgiffordI can't answer #17.1 or #17.2, but did test out the patch in #16 and it didn't change the defaults or the help text associated with the title element.
I could add in the existing page here:
Unfortunately I don't think we want the output to the page to be the same as the title of the page. So the results here:
You don't actually want to change the text out of the header. It would also be nice if the "Page #" were just a translated string that was available as a token rather than the raw page number.
And it doesn't treat the first page as special if you want to define it as " - Page #"
Hope this helps. It's moving along for sure.
Comment #19
mgiffordI think we're going to have to address this in 8.1.
Comment #23
jonathanshawComment #24
jofitz CreditAttribution: jofitz at ComputerMinds commentedRe-rolled.
Comment #25
Munavijayalakshmi CreditAttribution: Munavijayalakshmi at Valuebound commentedComments should (noramlly) begin with a capital letter and end with a full stop / period .
Fixed and attached new patch.
Comment #26
mikeker CreditAttribution: mikeker as a volunteer commentedAdds tests.
Comment #28
jonathanshawAddressing #18 would require extensive work, probably allowing to configure the page title separate from the view header.
I suggest it should be punted to a separate issue (or this patch moved to a separate issue), because what we have here is a ready-to-go, simple, effective enhancement. The current patch enables tokens in the title area, which before wasn't possible. It's a solid step forward.
Regarding #17.1 I notice that the LinkFormatter has
$link_title = \Drupal::token()->replace($item->title, [$entity->getEntityTypeId() => $entity], ['clear' => TRUE]);
i.e. it doesn't set an explicit langcode. There are not many examples of this in core to go by.
The langcode seems to be used by modules implementing hook_tookens. In core they tend to use a pattern like
or
So it looks like the langcode is optional and will tend to default sanely if omitted.
Comment #29
mikeker CreditAttribution: mikeker as a volunteer commented@jonathanshaw, thank you for the review and for providing feedback on #17.1. From what you're saying it sounds like it's fine that this code does not provide a langcode.
Agreed. And I believe this can be handled by the Metatag module, at least the part about the
title
tag being different from theh1
page title.Comment #33
PanchoApart from the tests a small patch that still applies cleanly on 8.7.x-dev and works as advertised.
IMHO a feature request, as the optional header already supports global tokens which for accessibility is sufficient.
Still a nice improvement.
We might want to add plural support as well, similar to #2888320: Add support for Token and plural in Views Global result summary plugin. We can do that in a followup, however.
If 8.7.x tests are passing this should be RTBC.
Comment #34
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commented#9:
I agree with this. Putting the page number in the
<title>
is highly desirable.It's definitely worth updating the default views config, for new installs, but we can leave existing sites alone. That can be deferred to a follow-up issue if needs be.
#11:
More specifically than WCAG success criterion 2.4.2 Page Titled at level A, there is SC 2.4.8 Location at level AAA. This is certainly something we can treat as level-A though; some level-AAA criteria are really just refinements of a more general concept at level-A.
A relevant WCAG technique is G127: Identifying a Web page's relationship to a larger collection of Web pages. This is close to the example 3 there (chapters of a textbook).
#28-29:
These suggest a follow-up should be filed for #18, to allow the visible heading and
<title>
to differ, so this should be filed before RTBC.#33:
I don't really follow what this means. The issue title says it's about allowing global tokens, but #33 says it already supports global tokens.
This could do with an issue summary update, about what is actually being changed here. In particular, the word "title" is ambiguous, as some comments are talking about the (visible) view title plugin, but it's clear that @DuaelFr is talking about the HTML
<title>
element. I think these are tightly coupled at present?Comment #39
mgiffordLinking open issues from the CivicActions Accessibility - VPAT.
Comment #44
mgiffordComment #45
needs-review-queue-bot CreditAttribution: needs-review-queue-bot as a volunteer commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #48
Bhanu951 CreditAttribution: Bhanu951 as a volunteer commentedRerolled patch 2509716-tokens-in-page-title.patch from #26 against 10.1.x and updated test.
Comment #49
Bhanu951 CreditAttribution: Bhanu951 as a volunteer commentedComment #50
smustgrave CreditAttribution: smustgrave at Mobomo commentedWas previously tagged for issue summary update and follow up which still appear to need and happen.
Also if there is a UX change before/after screenshots will be needed