欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

drupal7 views draggable field sorting 拖动字段排序 有大用

4 Answers  正确答案

  使用 Draggable Views 模块 


The Draggable Views module might be what you need. There is a version of the module for Drupal 8.

According to the module description,

DraggableViews makes rows of a view "draggable" which means that they can be rearranged by Drag'n'Drop.

I tried the following instructions in the documentation page on a vanilla Drupal 8.2.6 installation, and it worked fine (see screenshot below).

  1. Activate the module and navigate to the edit-page of an existing view.

  2. Now go to the Format section and choose Table.

  3. Make sure you have the "Content: Title" field, place it as your first field.

  4. Add the field "Draggableviews: Content" at the Fields section, place it after the "Content: Title" field.Make sure not to check "Exclude from display"; if you do the view will permit drag and drop but the changes will not be saved.

  5. Add "DraggableViews: Weight" at the Sort criteria section and place it as the first Sort criteria. Save the view and you're done.

enter image description here

shareimprove this answeredited Mar 6 at 15:33answered Feb 27 at 12:18dinopmi2,155514

   I've already tried it, but it does not let me assign a view with drag and drop as order criteria, in version 7 if you can, but in 8 only lets you sort by weight. – Fen Dev Feb 27 at 13:12   @FenDev - Sounds a little bit like a bug doesn't it? When draggable views ain't draggable. – leymannx Mar 1 at 16:06   @FenDev - I have just tried it with success and edited my answer accordingly. – dinopmi Mar 6 at 15:33   @dinopmi - In point 5 of your answer, when I make the view order interface I choose in the order criterion it only allows me to derive by weight, but in version 7 of drupal lets order a view by a view with Draggable View. I have already commented before that I only left by weight, but that is not functional when you create an interface to sort items from a view – Fen Dev Mar 8 at 9:43

You will need to create two set of views (lets say list view and order view) and they both should be sorted by draggableviews:weight. The order list view should be displayed as a table and should have draggableviews:content as one of its fields. See attached example.

Once this is setup, you can go back to list view and click on draggableviews:weight and select the newly created order view as sort order.

Let me know how you go.

STEP 1: enter image description hereSTEP 2: enter image description hereSTEP 3: enter image description here

shareimprove this answeranswered Feb 28 at 5:57Ash U36617

1 In drupal 8 the option "Display sort as" does not appear in configure sort criterion. – Fen Dev Feb 28 at 9:47   @FenDev - Then this sounds like a bug you should report on drupal.org. – leymannx Mar 1 at 16:04 

Have you tried Entityqueue? It is a drag and drop interface, in which you insert nodes and sort them.

You can then use the nodequeue as a relation, and sort criteria in views...

https://www.drupal.org/project/entityqueue

shareimprove this answeranswered Mar 3 at 21:13DjungleDev887

Refer this link, it may help. https://www.drupal.org/node/2824325

shareimprove this answeranswered Mar 8 at 11:24sarika38017

   @sarika-They have the same problem as me, they have not yet found the solution – Fen Dev Mar 8 at 11:41

来自 https://drupal.stackexchange.com/questions/229794/sort-content-of-views-with-drag-and-drop

普通分类: