I have a draggable table view with files as the base table and a category vocabulary exposed filter.

Everything is working as expected but when I save the view (the workflow was filter by term > change order > save) I get:

Notice: Undefined index: draggableviews_setting_view in draggableviews_contextual_links_view_alter() (line 180 of /home/user/site/dev/sites/all/modules/draggableviews/draggableviews.module).
Notice: Undefined offset: 1 in draggableviews_contextual_links_view_alter() (line 184 of /home/user/site/dev/sites/all/modules/draggableviews/draggableviews.module).

I have only just tried this out and got the error once and am now going to bed so I will have no more information but will investigate further tomorrow.

I am using latest stable drupal and views and latest dev of draggable views.

Comments

Niklas Fiekas’s picture

Yep, I have this on all pages that have a view that is not using DraggableViews.

rooby’s picture

Status: Active » Needs review
StatusFileSize
new1.42 KB

The problem actually occurs on any view where there is a 'weight' sort that isn't the draggable views weight sort.

When this module looks for its sort it specifically looks for sorts called 'weight', which is a problem since there are other sorts in views that use the same name (like taxonomy term weight for example).
Plus, in the case that there is another sort called weight before the draggable views one, then the draggable views one is called something like weight_1.

This patch changes the way the module identifies the draggable views weight sort to avoid all these potential problems.

Niklas Fiekas’s picture

Status: Needs review » Needs work

Thank you. One of the warnings is no longer occuring, but I still have:

Notice: Undefined offset: 1 in draggableviews_contextual_links_view_alter() (Zeile 184 von /home/.sites/919/site709/web/2011/sites/all/modules/draggableviews/draggableviews.module).

If you need a dumped variable to find the error, or if I can do anything else, please ask.

rooby’s picture

I can't reproduce that on mine.
It seems strange because it means you have a view with a draggable views weight sort that has the 'Display sort as' option set to a view that doesn't have a display.

If you dump the $view variable just before line 184 and then hit the page where you get that error it should give some insight and I might be able to work out what the problem is.

Also, you probably already have, but make sure you've cleared all your drupal caches and stuff as it is an odd problem.

Niklas Fiekas’s picture

StatusFileSize
new2.65 MB

Here you go.

rooby’s picture

Status: Needs work » Needs review
StatusFileSize
new1.64 KB

I think I know what is going on.

It seems you are using one view with a display for a slideshow and a display for sorting the slideshow with draggable views. Is that right?

If so your problem lies in using a single view. For now at least, this module requires that the view to be sorted and the draggable sorting view must be entirely separate views. Confusing I know but for now that is how it is, see #1392304: Allow using a different display of the same view for sorting

So once you have done that, in the weight sort for your slideshow you will be able to select the view you use for your draggable sorting.

In addition to that I have also made this amended patch that will also avoid the error you are seeing in this case (however your sort won't work as expected).

Niklas Fiekas’s picture

Status: Needs review » Reviewed & tested by the community

You're exactly right. Thank you! Now that I am using DraggableViews how it's supposed to be used (+ your patch) I no longer have warnings, and the sorting works always, not just randomly.

rooby’s picture

Excellent, thanks for testing the patch.

ygerasimov’s picture

Status: Reviewed & tested by the community » Fixed

Thank you for the great patch! Committed!

+++ b/draggableviews.moduleundefined
@@ -172,13 +172,14 @@ function draggableviews_contextual_links_view_alter(&$element, $items) {
     // Proceed only if order view is no self.
-    $order_view_display = $view->sort['weight']->options['draggableviews_setting_view'];
-    if ($order_view_display == 'self') {
+    // Also, just to be safe, make sure there is an order display.
+    $order_view_display = $view->sort[$sort_key]->options['draggableviews_setting_view'];
+    if ($order_view_display && $order_view_display == 'self') {
       return;

I this check is not really needed. So I have removed it.

brightbold’s picture

I was getting this error using today's dev, but solved it with the patch in #1410460: Breaking changes with commit b9acb58 or 22a0cd5 — undoubtedly this is a short-lived error but I wanted to report it in case anyone else is having this same problem today!

chrisschaub’s picture

Status: Fixed » Needs work

I don't think this patch is in the latest dev from git for 7.2.x, somehow. I see later commits from the 21st, but not this one. The code in #9 is not there -- but maybe you meant you didn't use it?

chrisschaub’s picture

Ok, I think this part is important:

    // Proceed only if order view is no self.
    $order_view_display = $view->sort['weight']->options['draggableviews_setting_view'];
    if ($order_view_display == 'self') {
      return;
    }

Notice: Undefined index: weight in draggableviews_contextual_links_view_alter() (line 180

Which come about because "weight" is something else or not defined. I think that part of the patch code needs to be committed, the #9 stuff you omitted, so that $order_view_display gets set correctly.

rooby’s picture

+++ b/draggableviews.module
@@ -172,13 +172,14 @@ function draggableviews_contextual_links_view_alter(&$element, $items) {
-    $order_view_display = $view->sort['weight']->options['draggableviews_setting_view'];
-    if ($order_view_display == 'self') {
+    // Also, just to be safe, make sure there is an order display.
+    $order_view_display = $view->sort[$sort_key]->options['draggableviews_setting_view'];
+    if ($order_view_display && $order_view_display == 'self') {
       return;
     }

Yes, this code has some parts that aren't strictly necessary as mentioned in #9 but also has parts that are necessary.

-    $order_view_display = $view->sort['weight']->options['draggableviews_setting_view'];
+    $order_view_display = $view->sort[$sort_key]->options['draggableviews_setting_view'];

These parts are necessary.

-    if ($order_view_display == 'self') {
+    if ($order_view_display && $order_view_display == 'self') {

These parts are not really necessary.

carwin’s picture

Subscribe

betoscopio’s picture

@carwin, please don't do that ... http://drupal.org/node/1306444

As cschaub says in #11, seems that the patch is not applied in dev. I'm using 2.x-dev from January 30 and still seeing the same error, but now the line is 192.

I try to apply the patch in #6 but i'm getting this error

$git apply -v draggableviews-get_real_weight_sort-1389440-6.patch

Checking patch draggableviews.module...
error: while searching for:
    $view->build($display_id);

    // Proceed only if there is weight sort criteria available.
    if (!isset($view->sort['weight'])) {
      return;
    }

    // Proceed only if order view is no self.
    $order_view_display = $view->sort['weight']->options['draggableviews_setting_view'];
    if ($order_view_display == 'self') {
      return;
    }
    list($order_view_name, $order_view_display_id) = explode(':', $order_view_display);

error: patch failed: draggableviews.module:172
error: draggableviews.module: patch does not apply

I think that the patch should be updated, but i'm not sure how to do that.

rooby’s picture

Yes, part of that patch has already been applied.

I'll reroll a new patch for the extra part that is needed tonight.

carwin’s picture

Still getting this error, though it does seem to be with less frequency than the last dev version.

Notice: Undefined offset: 1 in draggableviews_contextual_links_view_alter() (line 196 of /path/to/site/sites/all/modules/draggableviews/draggableviews.module).

From what I can tell it's really a random appearance. Sometimes it appears on nodes, sometimes it appears on views. I can't seem to find a real trigger for the cause.

rooby’s picture

Status: Needs work » Needs review
StatusFileSize
new539 bytes

Thanks for reminding me, I forgot to do that new patch.

Here is a new patch with the missing part.

ygerasimov’s picture

@carwin can you please confirm that patch from #18 solves your case?

carwin’s picture

@ygerasimov @rooby

Applied patch in #18 cleanly.

Error persisted.

Cleared cache.

Haven't seen it since. Thanks rooby.

----
edit:

Error returned.

rooby’s picture

What is your error message now?
Same one?
Same line number?

I didn't actually have time to test that patch as I'm using the on e in #6 still, but it should have worked.
I'll test the new one prorerly later.

rooby’s picture

Also, are you using latest dev?

carwin’s picture

Yep, latest dev, same error/notice and same line number.

rooby’s picture

I should also add that the patch in #18 is definitely necessary as it was left out of the patch in #6 when it was committed in #9.

I still have to check out carwin's error message.

ygerasimov’s picture

Status: Needs review » Needs work
StatusFileSize
new577 bytes

@roody, I have committed patch #18. I will very appreciate if you can help me with @carwin's problem.

@carwin it would very help if you can guide how exactly to reproduce the error. Could you please enable devel module and apply attached patch. It doesn't fix anything but will dpm() a view that throws error. It will very help if you can trace this view and explain how to create it. Hope in this way we can fix this error. Thank you a lot!

fernly’s picture

FYI: problem is still there in the 2012-Mar-06 dev release.

ygerasimov’s picture

@lennartvv, Could you please provide step by step instructions how to reproduce the error?

ygerasimov’s picture

Status: Needs work » Postponed (maintainer needs more info)
ak’s picture

I got the same error using DraggableViews 7.x-2.x-dev, 2012-Mar-16.
Notice: Undefined offset: 1 in draggableviews_contextual_links_view_alter() (line 182 …

kirkofalltrades’s picture

Same.

ygerasimov’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new833 bytes

Please review attached patch. I just have added extra check.

robertom’s picture

Hi ygerasimov, sorry for my bad english...

I have this problem and patch #31 works, but the problem is that $order_view_display is null, so I could use also the attached patch.

I have created 1 view with 4 display of type "content pane" (2 for order and 2 for display item).
This content pane is added to page with "page manager" and variants of type "panels".

I don't know why my $order_view_display is null

Thanks for your hard work

rooby’s picture

For the $order_view_display to be empty I would think you would have to have no draggable sort set up for your view.

Maybe an export of your view would help identify your issue.
If you can paste it into a text file and attach it keeps the issue cleaner.

Might be a good idea to add that extra check though to cover bases.

robertom’s picture

For the $order_view_display to be empty I would think you would have to have no draggable sort set up for your view.

You are right... now I have set "display sort as" for content pane that list items and notice is gone...

...also without extra check

thanks

edit: draggableviews sort criteria was configured, but I haven't setted the "display sort as" select list... so it was null

now is all ok

robertom’s picture

The patch #32 is needed when I go to the page that have incorporated the sortable "content pane"

Shadlington’s picture

#35 resolves this for me

ygerasimov’s picture

Status: Needs review » Fixed

Alright. I am happy to add this additional check. Committed. Thank you a lot.

Status: Fixed » Closed (fixed)

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