Link to the url of the view mode's display settings

Created on 15 August 2023, over 1 year ago
Updated 21 August 2023, over 1 year ago

Problem/Motivation

There may be utility in having a link to edit the view modes from the view mode usage report.

Proposed resolution

The view mode column could display a link, or there could be an entirely new column with this link. This would just need to be sure to link to the view mode of the bundle presented in the same row.

Feature request
Status

Active

Version

2.0

Component

Code

Created by

🇺🇸United States MegaKeegMan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @MegaKeegMan
  • 🇮🇳India mukhtarm

    Don't know i followed the correct path, but here is a patch that works. Also in the core view modes, we could see the delete option too in the Operations. thanks

  • 🇺🇸United States MegaKeegMan

    Thanks very much. I was surprised to see this patch this morning. One of the challenges here is that the url you have constructed will only link to the view modes for node entities. However, this module lists view modes on non-node entities as well. Taxonomy terms are one example, and there are many more. At the moment, I am not sure how to account for this, and this is part of my hesitation of trying to accomplish this task at all. I'm sure it is possible, but I am curious if there are any class methods on the entity that will help with retrieving the correct url, so that we don't have to set up any complicated conditionals.

  • 🇺🇸United States MegaKeegMan

    I don't believe there to be any such class method. But I believe we can do something like this, if you want to try it out:

    $url = Url::fromRoute('entity.entity_view_display.edit_form', [
      'entity_type' => $xvm_item->entity_type,
      'bundle' => $xvm_item->bundle,
      'view_mode' => $xvm_item->view_mode
    ]);
    

    Constructing the route manually won't work since these urls have some variation in their path structure.

  • 🇮🇳India mukhtarm

    Thanks for the update @MegaKeegMan

  • 🇺🇸United States MegaKeegMan

    After further investigation, I have found that the approach I stated above will not work. There is no existing general route for view mode display edit forms, as my example code would indicate. This means that in order for this to work, we would need to account for the variation in paths manually, which is stinky. If anyone has more knowledge of an appropriate way to do this, please share.

Production build 0.71.5 2024