See screenshot for wacky, wacky fun:

Views display horror

My initial thought was it'd be pretty straight-forward to just sort these in alphabetical order. Views that go together are often named in much the same way.

However, I asked Earl about this and he pointed out that auto-reordering becomes problematic because the order of these displays matters in the case where two displays have the same path.

So sounds like Views needs a mechanism to somehow manually control the order of displays. Earl says:

it probably wouldn't be that difficult to create a command that uses the drag & drop code to re-order displays. I wouldn't do it from the tabs themselves, that'd be gnarly.

Filing as a feature request.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

merlinofchaos’s picture

The easiest solution would be on the 'default' view under view settings, have a "Displays: Reorder" link which brings up a tabledrag list of displays and resets all their positions.

It would have to be sure that the weight range starts at 1, since Views expects the positions to start at 1 and increment up.

dawehner’s picture

Version: 6.x-2.x-dev » 6.x-3.x-dev
Issue tags: +views 3.x roadmap

adding a tag and pumping to the new version

superbaloo’s picture

subscribing

superbaloo’s picture

Status: Active » Needs review
FileSize
7.84 KB

I've done a little patch for this, here it is.

There is one last thing missing, i don't know how to make the browser refresh the page to display the new order after submission

I'm in the drupalcon, so if there is something wrong, that would be a pleasure to discuss about it :)

dawehner’s picture

FileSize
8.17 KB

Thats quite strange, the patch does not apply to views 3.x

Here is a fix, also uses drupalalike patch format.

superbaloo’s picture

Oops sorry for this.

Could you please give me the process to make a patch in the "drupal way" ? :) I'm not too accustomed to cvs command :p

what i've done was :

  • cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib checkout -r DRUPAL-6--3 contributions/modules/views
  • code
  • cvs diff > file.patch
dawehner’s picture

Sure

cvs diff -up > file.patch

Quite easy.

dawehner’s picture

Some minor things.

+++ includes/admin.inc
@@ -1820,6 +1821,209 @@ function views_ui_analyze_view_form_submit($form, &$form_state) {
+ */
+function _views_position_sort($a, $b) {
+  if ($a->position != $b->position) {
+    return $a->position < $b->position ? -1 : 1;
+  }
+
+  return 0;
+}

I don't like the naming of the variables. Why not use $display1 and $display2 or similiar.

What means return 0, why not FALSE.

This review is powered by Dreditor.

Why not change reorder with analyse, this seems to be more logically for me, because reorder belongs to the displays more then analyse.

superbaloo’s picture

FileSize
8.99 KB

Here is with the display1 and display2 var name

and, i'm returning 0 because it's 0 in the http://fr.php.net/manual/en/function.uasort.php documentation :)

I don't understand your last point, oculd you please be more verbose ? :p

superbaloo’s picture

Any update ?

dawehner’s picture

I don't understand your last point, oculd you please be more verbose ? :p

Basically switching the analyse button with your reorder button.

superbaloo’s picture

FileSize
9.02 KB

Here it is :)

superbaloo’s picture

FileSize
9.44 KB

Here is an update to my last patch to refresh the page by ajax

I still have some html in the code (only one line) may i move it into a new theme function.

dawehner’s picture

+++ includes/admin.inc	4 Sep 2009 07:44:22 -0000
@@ -1820,6 +1821,216 @@ function views_ui_analyze_view_form_subm
+                 l('<span>' . t('Remove') . '</span>', 
+                   'javascript:void()', 
+                   array(
+                     'attributes' => array(
+                       'id' => 'display-remove-link-' . $key, 
+                       'class' => 'views-button-remove display-remove-link', 
+                       'alt' => t('Remove this display'), 
+                       'title' => t('Remove this display')), 
+                     'html' => true));

MINOR. I don't like this i indent.

alt is not what links need.

+++ includes/admin.inc	4 Sep 2009 07:44:22 -0000
@@ -1820,6 +1821,216 @@ function views_ui_analyze_view_form_subm
+                     'html' => true));

MINOR: TRUE instead of true

+++ includes/admin.inc	4 Sep 2009 07:44:22 -0000
@@ -1820,6 +1821,216 @@ function views_ui_analyze_view_form_subm
+  $header = array('', t('Weight'), t('Remove'));

Why not having a header for the name. Perhaps this will also help the not so nice display of the header.

+++ js/base.js	4 Sep 2009 07:44:22 -0000
@@ -25,6 +25,14 @@ Drupal.behaviors.viewsTabs = function (c
     });
+  $('a.display-remove-link')
+    .addClass('display-processed')
+    .click(function() {
+      var id = $(this).attr('id').replace('display-remove-link-', '');
+      $('#display-row-' + id).hide();
+      $('#display-removed-' + id).attr('checked', true);
+      return false;
+    });

Can you explain why you are doing this. Perhaps a inline comment would be nice.

This review is powered by Dreditor.

superbaloo’s picture

FileSize
9.81 KB

Deleted displays handling

superbaloo’s picture

FileSize
9.92 KB

Corrections with #14 comment

For the indent issue, what do you propose ?

i've no idea which one could be better :(

dawehner’s picture

What about

<?php        
               $row[] = drupal_render($form[$id]['removed']) . 
                 l('<span>' . t('Remove') . '</span>', 
                   'javascript:void()', 
                   array(
                     'attributes' => array(
                       'id' => 'display-remove-link-' . $key, 
                       'class' => 'views-button-remove display-remove-link', 
                       'alt' => t('Remove this display'), 
                       'title' => t('Remove this display')), 
?>
superbaloo’s picture

FileSize
9.92 KB

Deal

dawehner’s picture

+++ includes/admin.inc	4 Sep 2009 08:47:14 -0000
@@ -1820,6 +1821,223 @@ function views_ui_analyze_view_form_subm
+      if (isset($display['removed'])) {
+        $row[] = drupal_render($form[$id]['removed']) . 
+                 l('<span>' . t('Remove') . '</span>', 
+                   'javascript:void()', 
+                   array(
+                     'attributes' => array(
+                       'id' => 'display-remove-link-' . $key, 
+                       'class' => 'views-button-remove display-remove-link', 
+                       'alt' => t('Remove this display'), 
+                       'title' => t('Remove this display')), 
+                     'html' => TRUE));

Its still in.

I'm on crack. Are you, too?

superbaloo’s picture

FileSize
9.86 KB

Humpf ... didn't generate the .patch ... that was the old one !

sorry for this

dawehner’s picture

+++ js/base.js	4 Sep 2009 09:49:29 -0000
@@ -25,6 +25,16 @@ Drupal.behaviors.viewsTabs = function (c
+   * (checking in the hidden checkbox and hiding out the row) */

MINOR: make a line break for */
I would use perhaps just the second line as description

I'm on crack. Are you, too?

superbaloo’s picture

FileSize
9.84 KB

Here we go

superbaloo’s picture

FileSize
10.52 KB

Little css fix

merlinofchaos’s picture

Status: Needs review » Needs work

During testing, I had a view with 8 or 9 displays. I was playing around, removing, restoring, removing, restoring, reordering. When I was done, I hit save. All but 1 display got removed.

I tried to reproduce this and couldn't, so I'm not sure what triggered it.

SeanBannister’s picture

Sub

superbaloo’s picture

ok, i would test it as soon as i would get my dev server back ! :)

dagmar’s picture

Mmm, I test this patch with 20 displays and cannot reproduce #24.

Maybe the better way to see if this patch works is using Simpletest.

However, write this kind of test can be a painful task.

@superbaloo Do you have any news?

merlinofchaos’s picture

Status: Needs work » Needs review

Alright, I will give this another try and see if I can make that happen again.

dawehner’s picture

I did some testing which some kind of crazy views, with a lot of displays fields arguments sorts etc. It worked well...

I wouldn't suggest anyone to use 6.x-3.x on production site. So why not get this done and get more people testing this.

merlinofchaos’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Status: Needs review » Patch (to be ported)

Well, I can't get it to happen again, so I've committed this.

1) I don't really like the UI, adding the button in the empty space on the left has it pretty out of the way. Maybe we need to retool the UI there. That said, I think that's a bigger project than just this patch, and we can come back and address UI later once we've got the functionality there, and get folks like yoroy and Bojhan to come up with some suggestions.

2) Didn't apply to 7.x; hardly surprising.

Note: I made one correction in the patch. There is a reference to $form[$id] that is wrong and must be replaced with $form[$key] -- this error should generate notices, so when porting to 7.x be sure notices are on.

dawehner’s picture

Status: Patch (to be ported) » Needs work
FileSize
11.37 KB

Puh patch still needs work:
submit or reorder does not work

nbluto’s picture

subscribing

YK85’s picture

subscribing

Francewhoa’s picture

+1 Subscribing

Brodingo’s picture

Subscribing

AlanAtLarge’s picture

subscribing

pippal’s picture

Subscribing

dmitrig01’s picture

I don't see how reordering displays is useful - does it have any bearing on anything?

dawehner’s picture

For example if you realize that you need a feed display for two/three different page displays. So it would make sense to have the feed display below the coresponding page display.

webchick’s picture

Yeah, see the screenshot in the OP.

He's got a display for "News" and "Coaches" and sometime later decided he needed additional attachment views for those. So now those are at the bottom, not visually close at all to their "parent" views, and it'd be much easier to grok if they were.

Of course, one could argue that one shouldn't build views with 127 displays, but hey. ;) It happens.

dawehner’s picture

FileSize
11.32 KB

Reroling. It's still not working 100%

adam_b’s picture

subscribe

zevans23’s picture

Subbing

dawehner’s picture

Status: Needs work » Fixed

Some hours later this feature is now ported.

Status: Fixed » Closed (fixed)

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

botris’s picture

Tried #20 on views 6.x-2.12, after resaving the modules all works fine.
IMHO together with views_clone_display, it's a killer combo.