Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem:
- Views has contextual links that appear when a View is rendered as a page, and those contextual links appear to the right of the page title (the <h1>
element), but the code Views uses to achieve this is ugly: see views_page_alter(), views_preprocess_html(), and views_contextual_links_view_alter().
- As of #1874664: Introduce toolbar level "Edit" mode that shows all contextual links, contextual links for nodes now appear on the node page itself, but they are attached to the node's <article>
tag, which does not include the page title.
Questions:
- Do we want to continue the pattern of contextual links used for main page content? Much of #1874664: Introduce toolbar level "Edit" mode that shows all contextual links was about answering yes to that question, but that was not the original intent of contextual.module for D7.
- If we do, do we want the contextual-region including the
<h1>
tag, as in how views pages currently works, or not, as in how node pages currently work? - Most page.tpl.php implementations currently print $tabs in between the page title and the main content. Is there a legitimate use case for tabs and main content contextual links both appearing, or should they always be mutually exclusive?
- If we do want to encompass the page title, how do we need to change our page.tpl.php rendering pipeline to support that cleanly, so we can remove the current Views hacks?
Comments
Comment #1
Wim LeersI can offer another angle…
The real problem here is Drupal's "page title" concept.
If a node is rendered in the teaser view mode, then the node title is inside the
<article class="node">
tag, i.e. all of the node's fields are properly contained. The "page title" is something else than the node title.But, if a node is rendered in the full view mode, then the node title is outside the
<article class="node">
tag, i.e. not all of the node's fields are properly contained. The "page title" is the node title.The latter caused a lot of hackery to make in-place editing work for node titles, because the semantic structure is no longer accurate.
Comment #2
Gábor HojtsyI think there is very well a use case for contextual links and tabs appearing. For example, Views is regularly used to create different pages using tabs between them as navigation. The tabs are not actions on the views, but rather each tab is a view or a different display of a view. So the contextual link actions are on the View but the tabs are unrelated to the view's backend tasks.
Experimenting with adding contextual links to taxonomy term pages in #1915730: Decide what to do about important contextual links when that module is disabled or restricted also showed that if all of the content of the object is a title (ie. no description on the term), then there is nothing to display below the title before the list of nodes is displayed, so if contextual links are used in place of tabs, then there is no place to display them. If you enter a description, it will naturally provide space for the contextual links (like the node body or any other first field or authoring information on the node).
So I think there is a strong case to be made that the "main page object's" contextual links would be ideally carried over to the page title (if there is one) or the page title be made part of the main page object in containment (like Wim alluded to above).
Comment #3
jhedstromProbably needs to wait until 8.1.
Comment #4
effulgentsia CreditAttribution: effulgentsia commentedIt's been a while since I opened this. Some of what's in the original issue summary might have already been fixed. In which case, are there any problems left with what's in HEAD? Depending on the answer, some might still be solvable without disrupting APIs, or we can close this issue entirely, so moving back to 8.0.x until that's answered.
Comment #5
Wim LeersChanges since February 2013
It's actually in exactly the same state as it was before; none of this architecture has changed, so the same problems exist.
BUT:
$page['#title']
(where$page
is the render array returned by the main content controller) is now allowed to be HTML. So this part from the IS is not actually a problem anymore: .#contextual_links
property set. That works just fine. I don't think it makes sense to abstract it away furtherThe 4 questions
To answer the 4 questions in the IS:
Comment #16
larowlanIs item 2 less of an issue now that quickedit is out of core?