I'm not sure if this is intended functionality, but I got a mess of errors when creating a draggable table. I had everything set up correctly according to the tutorial here but was getting this error message when I navigated to the page:
* Notice: Undefined property: stdClass::$nid in _draggableviews_info() (line 187 of /www/fronteer/public/sites/all/modules/contrib/draggableviews/draggableviews.inc).
* Notice: Undefined property: stdClass::$nid in _draggableviews_info() (line 187 of /www/fronteer/public/sites/all/modules/contrib/draggableviews/draggableviews.inc).
* Notice: Undefined property: stdClass::$nid in _draggableviews_info() (line 187 of /www/fronteer/public/sites/all/modules/contrib/draggableviews/draggableviews.inc).
* Notice: Undefined property: stdClass::$nid in _draggableviews_info() (line 187 of /www/fronteer/public/sites/all/modules/contrib/draggableviews/draggableviews.inc).
* Notice: Undefined property: stdClass::$nid in draggableviews_view_draggabletable_form() (line 145 of /www/fronteer/public/sites/all/modules/contrib/draggableviews/draggableviews.module).
* Notice: Undefined property: stdClass::$nid in draggableviews_view_draggabletable_form() (line 145 of /www/fronteer/public/sites/all/modules/contrib/draggableviews/draggableviews.module).
* Notice: Undefined property: stdClass::$nid in template_preprocess_draggableviews_view_draggabletable() (line 150 of /www/fronteer/public/sites/all/modules/contrib/draggableviews/draggableviews_theme.inc).
* Notice: Trying to get property of non-object in template_preprocess_draggableviews_view_draggabletable() (line 158 of /www/fronteer/public/sites/all/modules/contrib/draggableviews/draggableviews_theme.inc).
* Notice: Undefined property: stdClass::$nid in template_preprocess_draggableviews_view_draggabletable() (line 150 of /www/fronteer/public/sites/all/modules/contrib/draggableviews/draggableviews_theme.inc).
* Notice: Trying to get property of non-object in template_preprocess_draggableviews_view_draggabletable() (line 158 of /www/fronteer/public/sites/all/modules/contrib/draggableviews/draggableviews_theme.inc).
I did some quick debugging and noticed that on the lines stated in the error message, there was common access to an object property ($view->base_field):
<?php
// Line 187 of dragableviews.inc
$info['nodes'][$row->{$view->base_field}]['order'][0]
// Line 145 of draggableviews.module
$nid = $result->{$view->base_field}
//This one only comes up after you hit 'submit'
// Line 466 of draggableviews.module
$info['input'][$row->{$view->base_field}]['order'][0] = $input[$info['order']['field']['field_name'] . '_' . $row->{$view->base_field}];
//
?>
I dpm'd a few of the variables and noticed that $view->base_field was looking for a nid, which I hadn't specified as a Field in my View. Adding the node's nid as a field to my View fixed the problem.
I did a check through the documentation for mention of requiring the nid to be a field but couldn't find anything. I'm mostly just wondering if this is intended functionality? It's not really an inconvenience (you can just add the field and make it hidden from view) but it would be good to document it if it is a requirement.
Thanks! Great Module by the way!
Comments
Comment #1
brightboldI got this same error in a slightly different format:
But I can confirm that adding nid to the fields solves the problem - thanks for the tip @drclaw!
Comment #2
drclaw commentedGlad this helped!
I think I know why this *bug* has gone generally unnoticed: Views 3.
It's not actually a Drupal 7 or a DraggableViews issue, it's really just that Views 3 needs the nid to be explicitly stated in the fields of your view. In Views 2, you didn't need to specify it, it was available by default.
Still think it should be documented though! *wink*
Comment #3
eaton commentedThis appears to be a problem with some shuffling in the Row Style handlers. Previously in Views, the base field was always added to most queries. Now, it appears that's handled by the row style. A snippet of code something like this probably needs to be added to DV's row style plugin:
Comment #4
ginc commentedshall we patch the module or document it?
Comment #5
user654 commented.
Comment #6
istryker commentedThis is an issue for 7.x-1.x-dev, which is unsupported now. There is no problem like this in 7.x-2.x-dev or 7.x-2.0. Closing issue.