Problem/motivation
The links field is not being displayed when using custom view modes.

Steps to replicate:

  1. Fresh install
  2. Create custom view mode (Screenshot 2662898-view-mode-create)
  3. Configure view mode to have links enabled and is available to use with 'Article' content type (Screenshot 2662898-view-mode-enable and 2262898-view-mode-setup)
  4. Create some content of content type 'Article'
  5. Create a view that displays 'Article' content type with the new view mode (Screenshot 2662898-view-setup)
  6. Check the view preview if it has 'links' visible (Screenshot 2662898-view-preview)

Proposed resolution
To display a read more link in all view modes excluding the full and default view rather than just teaser.

Issue fork drupal-2662898

Command icon 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

ultimike created an issue. See original summary.

swentel’s picture

Title: "Lists" field not displaying on custom view modes » "Links" field not displaying on custom view modes
Component: render system » entity system

Hmm, it is kind of confusing. The thing is that the links field calls out to methods/modules and asks if there are any links. Problem is that most links in core right now are only displayed on full or teaser view mode because it makes sense in that context only.

e.g. a 'Read more' link makes sense on 'teaser', not on 'full', but it doesn't know if it's relevant for other view modes. See #1837100: Provide a generic Read more field for that.

Maybe the formatter of the links should have the ability to collect all potential links, present a form and then you can configure which ones to show.

Belongs more to the entity system than the render system.

berdir’s picture

The entity system doesn't know about links, that's node/comment specific :)

Yeah, links are a mess and mostly hardcoded. The only reason we made it an extra field is to be able to hide them when you don't want them.

Not really sure what to do, maybe the display component issue would provide an approach to explicitly define link link components and control their visibility without making each of them a separate extra field?

swentel’s picture

Component: entity system » node system

Yeah, belongs to the node system indeed.

thamas’s picture

The same problem occurs when one tries to display the tags field of the default article content type in a custom view mode.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

willzyx’s picture

Status: Active » Needs review
StatusFileSize
new957 bytes

The only reason we made it an extra field is to be able to hide them when you don't want them.

So instead of show links only for the the teaser view mode we could show link for every view mode (excluding the full and the default view mode).. isn't it? Not sure if for comment links this has sense but for node read more link it does fore sure

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

tommychris’s picture

Status: Needs review » Reviewed & tested by the community

I think this aspect is the good aspect.

tstoeckler’s picture

Status: Reviewed & tested by the community » Needs work

The latest patch does not pass tests, so it certainly cannot be committed.

sharique’s picture

Version: 8.3.x-dev » 8.4.x-dev

Old patch does not apply, so re-rolling based on latest code base 8.4.x.

sharique’s picture

Status: Needs work » Needs review
sharique’s picture

StatusFileSize
new942 bytes

Forgot to upload file.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

opi’s picture

Status: Needs review » Reviewed & tested by the community

Works as expected, thanks !

berdir’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

This can't be committed without tests, it might also need to be configurable, because not everyone wants those links and now with the update, they might suddenly show up, likely breaking designs.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Anonymous’s picture

#14 did the treat, but I agree with @Berdir that this could be classed as a regression. However I feel it would be an acceptable thing to note when upgrading to a new minor version, so could it just be included in say 8.7.x? Give people enough time to adapt...

krzysztof domański’s picture

Status: Needs work » Needs review
StatusFileSize
new2.86 KB

New patch with test.

zanvidmar’s picture

I can confirm that patch #21 works with Drupal core 8.6.4

vj’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new37.93 KB
new36.46 KB

#21 works with 8.7.x

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

As per #17 I think we need to consider BC here. If we suddenly add links to people's custom view modes there is a good chance we'll break there designs / have unintended impacts.

mpp’s picture

I just read #823380 which contains a lot of discussion on whether it's a bug or not. Fact is that the title in this issue describes the real bug: it's not possible to show the links field on view modes other than teaser.

mpp’s picture

Status: Needs work » Closed (duplicate)

@alexpott, I agree with @Maffoo in #20. I hope we can make this happen for 8.7.

I can also confirm that patch #21 works with Drupal core 8.6.4

mpp’s picture

Status: Closed (duplicate) » Needs work

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

rosk0’s picture

Patch #21 works with Drupal core 8.6.13.

Not sure how this change could be BC issue because "Links" field can be removed from output by simple config change.

So, IMHO, RTBC.

geoffray’s picture

Patch #21 works as expected with Drupal 8.6.1, thanks.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Anonymous’s picture

I can confirm patch #21 works great with Drupal core 8.7.8, thank you.

capysara’s picture

The regression concern relates to step #4 in the original issue summary: Configure the new custom view mode to display the "Links" field.

The problem is: you don't have to configure the new custom view mode to display the Links field. The configuration is "enabled" by default. You have to explicitly "disable" the Links field from Manage Display, and many users may not have disabled it because it doesn't display regardless (except on the Teaser).

If you apply the patch, but have not explicitly disabled the Links field (in all of your custom view modes for all of your entities), then the Links field will display, which could be very disruptive for existing sites.

#17 suggested a config option, but what’s the best way to approach that? Sitewide, per node type, per view mode? There would need to be something at the View Mode level that tells users that the Links field is, by design, only enabled for the Teaser display (no matter what the config says), and that if you want it to display on custom view modes, you need to enable this other new configuration. And then you would need a Warning so users know that the Links field is going to display unless they’ve disabled it.

IMO, the issue is more general (and maybe there's already a ticket about this). There’s a configuration presented to the user, but it’s not really configurable. There’s a Links field that’s “enabled” by default, but it’s only configurable for the Teaser display. The purpose of this functionality is to prevent users from adding a Read more link on the full content because it wouldn’t be logical to add a link back to itself. It’s a good safety measure, but it creates a confusing UX.

krzysztof domański’s picture

Version: 8.9.x-dev » 9.0.x-dev
Issue tags: -Needs tests
StatusFileSize
new1.08 KB
new2.77 KB

1. Will Drupal 9 release notes be enough? There are many view modes, e.g. "Search index" in which we can break design.

2. The big problem is that the configuration is "enabled" by default. See #33. We also cannot change config globally and hide Links in hook post update. Many projects uses the previous patch...

krzysztof domański’s picture

Status: Needs work » Needs review
krzysztof domański’s picture

Status: Needs review » Needs work
krzysztof domański’s picture

Status: Needs work » Needs review
StatusFileSize
new764 bytes
new2.9 KB
catch’s picture

Does this only affect the read more link, what about the counter from the statistics module, or the comment module links?

andypost’s picture

This kind of links used in comment entity as well, would be great to unify them in follow-up

krzysztof domański’s picture

Even if we hide all links that are not displayed by default it can also have a negative impact. Many people use the patch (30 followers). If we hide the read more links it will be troublesome for them to re-enable the links again... For example, if they were disabled in one view mode but disabled in another.

kentr’s picture

Patch #37 is working to display the "Read more" link for me, Drupal 8.8.7.

xjm’s picture

Version: 9.0.x-dev » 8.8.x-dev
kentr’s picture

After using this patch for a while, I've noticed that theming the links per view mode doesn't follow the conventions for other fields.

It would be immensely helpful if the links field used standard theming conventions, such as template suggestions related to the view mode.

BalajiDS’s picture

Issue summary: View changes
StatusFileSize
new26.04 KB
new27.13 KB

Patch #37 is working fine, Drupal 8.8.6.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

johnpitcairn’s picture

Version: 8.9.x-dev » 9.3.x-dev

Patch at #37 applies to 9.1.x and works as expected. Would be RTBC but this needs to be against 9.3.x dev now...

akhildev.cs’s picture

hi,
patch #37 not applicable on drupal 9.3.x-dev.
failed to apply.

akhildev.cs’s picture

StatusFileSize
new2.91 KB

patch #37 re-roled.
please review.
Thankyou.

Status: Needs review » Needs work

The last submitted patch, 49: 2662898-49.patch, failed testing. View results

meenakshi_j’s picture

StatusFileSize
new2.96 KB
new1.41 KB

Fixed the #49 test case issue.

meenakshi_j’s picture

Status: Needs work » Needs review
manojithape’s picture

Assigned: Unassigned » manojithape
manojithape’s picture

Assigned: manojithape » Unassigned

Not able to reproduce this issue.

jannakha’s picture

Status: Needs review » Reviewed & tested by the community

it works! pls move to core soon!

quietone’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Bug Smash Initiative, +Needs issue summary update

Thanks to everyone for the work here and the confidence that this is working. However, there are more steps needed before this is RTBC, see core gates.

First, this needs an issue summary update, in fact, it needs an issue summary! Add include before and after screen shots in that.

I don't see any evidence of a review of the fix or the new test.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

hawkbreeze’s picture

Hi all,
I have not used Drupal for years and have recently installed Drupal 9.4.3. I am seeing this issue. Even though this issue specifies 9.5.x-dev, does this also affect previous versions? Even the "stable" release?

rakhi soni’s picture

rakhi soni’s picture

Status: Needs work » Needs review
StatusFileSize
new2.98 KB

Kindly review patch for version 9.5x,,

himanshu_jhaloya’s picture

Assigned: Unassigned » himanshu_jhaloya

I will review the patch.

bnjmnm’s picture

Status: Needs review » Needs work

There was no reason for the 9.5 reroll in #61, the testbot indicates that patch #51 still applies fine to 9.5. #61 is the same patch aside from an additional few bytes of whitespace that fail PHP coding standards. Preemptively removing credit for that.

It also shouldn't have been set to "needs review". It was set to "needs work" in #56 because work was requested, and that work hasn't. been done yet.

Anonymous’s picture

I've tested the issue reported here (Php:8.0.10, Drupal:9.5.x-dev) and I can replicate it following the steps provided in the summary. After applying the patch in #51 the links appeared (Screenshot: 2662898-view-preview-w-patch).

As user quietone pointed out in #56, this needs to be further reviewed to be compliant with the policies specified in the core gates.

I'm leaving this issue as needs work as the core gates still need to be checked if they're passed.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

himanshu_jhaloya’s picture

Assigned: himanshu_jhaloya » Unassigned
anchal_gupta’s picture

StatusFileSize
new2.98 KB
new502 bytes

Fixed CCF Error
Upload patch against 10.1x

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

VladimirAus made their first commit to this issue’s fork.

vladimiraus’s picture

Status: Needs work » Needs review

Moved patch to MR.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

Believe the issue summary still needs work. "Apply patch" is not a solution, what is the actual proposed solution to address the bug at hand?

vladimiraus’s picture

Issue summary: View changes

The solution as per code to display a read more link in all view modes excluding the full and default view rather than teaser.

Updated summary.

vladimiraus’s picture

Status: Needs work » Needs review
smustgrave’s picture

So my concern is if this is going to make a read more link appear for a bunch of view modes now.

vladimiraus’s picture

@smustgrave I guess so.
We can add hook_update and hide it for all view modes but teaser by default.
Ideas? 🤔

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: -Needs issue summary update +Needs upgrade path

Think that would be best. Maybe even on teaser check if the links is currently hidden, if so leave it alone.

Just thinking a bunch of view modes like cards start having links appear.

acbramley’s picture

Status: Needs work » Postponed (maintainer needs more info)

We have a hook_node_links_alter that is called via NodeViewBuilder::renderLinks. Modules could use this to add the Read more or any other link to any view mode they like.

This avoids core having to do any work or upgrade path.

What if non teaser view modes were showing links for other purposes? Now they'd need to alter out the read more link.

I think this should probably just be closed as works as designed.

smustgrave’s picture

Wanted to give one more bump for any response to #80

smustgrave’s picture

Wanted to give 1 more change since this had a lot of early conversation.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

luke.stewart’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

This has floated to the top of the Bug Smash Initiatives target - it's current the least recently modified - PMNMI issue.

Reading over the above it looks like a solution was developed and worked on - but no agreement could be reached as to how it could be deployed as doing so would result in breaking changes, and an upgrade path to handle the various possibilities was floated as not being possible.

Without any further feedback and two rounds of bumping without any further feedback I think we follow suggestion in 80 and close as works as designed.

If you have suggestions as to how we could manage the breaking nature of this change and why it shouldn't be handled in a contrib module as suggested in 80 please reopen and include this.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.