We have new add/edit view mode functionality in core. Cool! Over in #2409545: Custom block view mode should only display if there's more than one we were looking at how to best aid discoverability of view modes

I initially looked at adding a button, but a simple text link in custom display settings should do it, plus a small change to the checkbox label.

view modes

This would need to be implemented on the manage display tab of nodes, users, taxonomy terms, custom blocks and comments.

Comments

mayurjadhav’s picture

Issue tags: +#DCM2015
StatusFileSize
new1.36 KB

I have implemented the changes in manage display of all entities.
please find the patch.

Thanks,
Mayur Jadhav.

chris_h’s picture

Status: Active » Reviewed & tested by the community
StatusFileSize
new165.37 KB

Manually tested and works as expected - nice simple usability improvement

view modes

amateescu’s picture

Component: system.module » field_ui.module
Status: Reviewed & tested by the community » Needs work

The same link and text is displayed if you go to the 'Manage form display' tab, which is not good :) Over there we need to change the link and the text to "Manage form modes".

mayurjadhav’s picture

I have created a new patch with different display context modes.

mayurjadhav’s picture

Status: Needs work » Needs review

The last submitted patch, 1: increase-discoverability-of-view-modes-2409591-1.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 4: increase-discoverability-of-view-modes-2409591-4.patch, failed testing.

amateescu’s picture

+++ b/core/modules/field_ui/src/Form/EntityDisplayFormBase.php
@@ -237,10 +238,20 @@ public function form(array $form, FormStateInterface $form_state) {
+          '#title' => $this->t('Use custom display settings for the following ' . $this->displayContext . ' modes'),
...
+          '#markup' => \Drupal::l(t('Manage ' . $this->displayContext . ' modes'), $url),

You can not do string concatenation like this in the t() function, any dynamic string has to be sent as a parameter, as explained in https://api.drupal.org/api/drupal/core!includes!bootstrap.inc/function/t/8 and https://api.drupal.org/api/drupal/core!lib!Drupal!Component!Utility!Stri....

Also, instead of trying to do everything in the base class, it would be cleaner if you provide the element like this:

$form['modes']['display_modes_link'] = $this->getDisplayModesLink();

provide an abstract method getDisplayModesLink() in the base class and implement it in each extending class with the proper titles and urls.

amateescu’s picture

This also needs a sign-off from someone in the usability team to decide if it's a good thing to do or not. The issue is already tagged so we just need to wait :)

mayurjadhav’s picture

As I'm new in drupal 8 sorry for my poor coding.
I'll provide a proper patch with drupal 8 coding standards.

vbouchet’s picture

This ticket seems related.

vbouchet’s picture

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.

yoroy’s picture

Version: 8.1.x-dev » 8.2.x-dev
Priority: Minor » Normal
Issue tags: +ux-workflow
yoroy’s picture

Issue tags: +DevDaysMilan
marcoscano’s picture

Assigned: Unassigned » marcoscano
marcoscano’s picture

Assigned: marcoscano » Unassigned
Status: Needs work » Needs review
StatusFileSize
new3.64 KB

Patch attached refactors #4 and implements the suggestions from #8.

Status: Needs review » Needs work

The last submitted patch, 17: add-link-to-display-modes-management-2409591-17.patch, failed testing.

pguillard’s picture

Assigned: Unassigned » pguillard

The last submitted patch, 17: add-link-to-display-modes-management-2409591-17.patch, failed testing.

pguillard’s picture

Assigned: pguillard » Unassigned
Status: Needs work » Needs review
StatusFileSize
new3.33 KB
new1.54 KB

I guess we know already the routes names, why not use them explicitly ?
I found that trying to get a way to pass the tests.

   protected function getDisplayModesLink() {
-    // Get the route name.
-    $url_object = \Drupal::service('path.validator')->getUrlIfValid('admin/structure/display-modes/form');
-    $route_name = $url_object->getRouteName();
 
     return [
       '#type' => 'link',
       '#title' => t('Manage form modes'),
-      '#url' => Url::fromRoute($route_name),
+      '#url' => Url::fromRoute('entity.entity_form_mode.collection'),

and

protected function getDisplayModesLink() {
-    // Get the route name.
-    $url_object = \Drupal::service('path.validator')->getUrlIfValid('admin/structure/display-modes/view');
-    $route_name = $url_object->getRouteName();
+  protected function getDisplayModesLink() {;
 
     return [
       '#type' => 'link',
       '#title' => t('Manage view modes'),
-      '#url' => Url::fromRoute($route_name),
+      '#url' => Url::fromRoute('entity.entity_view_mode.collection'),
artusamak’s picture

artusamak’s picture

The patch looks OK to me. I've tested it and it works as expected.
I just attached a patch to remove some unwanted line breaks and rephrased the abstracted method.

swentel’s picture

+++ b/core/modules/field_ui/src/Form/EntityDisplayFormBase.php
@@ -205,10 +205,12 @@ public function form(array $form, FormStateInterface $form_state) {
+        // Provide link to manage viewmodes.

Should probably be something like 'Provide link to manage display modes.'

pguillard’s picture

Update with suggestion at #24

ifrik’s picture

StatusFileSize
new17.36 KB

Thanks,
on the Manage display page in Custom display settings section, there is now a link Manage view modes, and on the Manage form display there is Manage form modes.
Both provide simply links for users who want to use additional form or view modes, and first checked whether there already is a suitable one that only needs enabling. This is also useful for users who were not aware that they can create additional modes.

ifrik’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new10.77 KB

Screenshots:


  • catch committed ee26b4b on 8.2.x
    Issue #2409591 by pguillard, mayurjadhav, Artusamak, marcoscano, chris_h...
catch’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +String change in 8.2.0

Looks good to me, I had trouble finding that page just last week.

PHPCS: core/modules/field_ui/src/Form/EntityDisplayFormBase.php passed

FILE: ...8.x/core/modules/field_ui/src/Form/EntityFormDisplayEditForm.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 9 | WARNING | [x] Unused use statement
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Time: 25ms; Memory: 4Mb


FILE: ...8.x/core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 9 | WARNING | [x] Unused use statement
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Fixed these on commit.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.