When DraggableViews is used with another Content entity (non-node) errors are shown when the hierarchy functionality is used. The Drupal\draggableviews\DraggableViews class seems to assume an identifier is always called 'nid', while it can have arbitrary names.

I think the solution should be to inspect the view's base entity type for the identifier field, and use that field in the depth calculation.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

marcus_w created an issue. See original summary.

marcus_w’s picture

Patch is attached

marcus_w’s picture

Added fix for infinite depth

nicxvan’s picture

Title: DraggableViews only handles nid as identifier » Support identifiers other than nid
Version: 8.x-1.x-dev » 2.1.x-dev
Category: Bug report » Feature request
mandclu’s picture

Status: Active » Needs review
tonka67’s picture

Thanks for reopening this. Looks like there's been a reversion in DraggableViews 2.1.4. I'm pulling the following error again:

Warning: Undefined property: Drupal\views\ResultRow::$nid in Drupal\draggableviews\DraggableViews->getIndex() (line 44 of /code/web/modules/contrib/draggableviews/src/DraggableViews.php)

istryker’s picture

Is this a duplicate of #3158196: Allow any entity in DraggableViews::getIndex(). To me it looks the same, but this one tries to make hierarchery work

istryker changed the visibility of the branch 2.1.x to hidden.

  • istryker committed ea882a72 on 2.1.x
    Issue #2985291 by istryker, marcus_w: Support identifiers other than nid
    
istryker’s picture

Title: Support identifiers other than nid » Support identifiers other than nid (whatever the base entity of the view is)
Status: Needs review » Fixed

I fixed things up a little. I renamed everything 'base view entity id' cause that's what it is. This should support any entity type that can be a view. The only thing that might be a problem is crossing different type of relationships in the view. I am not too worried about this though, as that is probably already broken.

Status: Fixed » Closed (fixed)

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