Hello all,

I've got a vocabulary which I would like to use with Views and create a draggable ordering view. I'm having a few problems with the taxonomy handler example. Essentially I just want to list the terms in a view and have the drag handle next to the term names and enable the user to reorder those terms.

Any advice would be much appreciated!

Welly

Comments

welly’s picture

Giving this a little bump

welly’s picture

Ok, i've figured this out and got the functionality working fine. However, it does have a tendency to display warning messages saying "Draggableviews: A cycle was found.". Would anyone have any ideas why this is occurring?

Thanks

welly’s picture

Another bump!

sevi’s picture

Which version of DraggableViews are you using? This really shouldn't be :\

I paste here the views export code of a simple draggable taxonomy view.. just for the case you need.

Greetings,
sevi

$view = new view;
$view->name = 'draggabletax';
$view->description = '';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'term_data';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('relationships', array(
  'parent' => array(
    'label' => 'Parent',
    'required' => 0,
    'id' => 'parent',
    'table' => 'term_hierarchy',
    'field' => 'parent',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('fields', array(
  'name' => array(
    'label' => 'Term',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'link_to_taxonomy' => 0,
    'exclude' => 0,
    'id' => 'name',
    'table' => 'term_data',
    'field' => 'name',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
  'weight' => array(
    'label' => 'Weight',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'exclude' => 0,
    'id' => 'weight',
    'table' => 'term_data',
    'field' => 'weight',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
  'tid' => array(
    'label' => 'Term ID',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'set_precision' => FALSE,
    'precision' => 0,
    'decimal' => '.',
    'separator' => ',',
    'prefix' => '',
    'suffix' => '',
    'exclude' => 0,
    'id' => 'tid',
    'table' => 'term_data',
    'field' => 'tid',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'parent',
  ),
));
$handler->override_option('sorts', array(
  'weight' => array(
    'order' => 'ASC',
    'id' => 'weight',
    'table' => 'term_data',
    'field' => 'weight',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('filters', array(
  'vid' => array(
    'operator' => 'in',
    'value' => array(
      '2' => '2',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'vid',
    'table' => 'term_data',
    'field' => 'vid',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler->override_option('use_pager', '1');
$handler->override_option('style_plugin', 'draggabletable');
$handler->override_option('style_options', array(
  'override' => 1,
  'sticky' => 0,
  'order' => 'asc',
  'columns' => array(
    'name' => 'name',
    'weight' => 'weight',
    'tid' => 'tid',
  ),
  'info' => array(
    'name' => array(
      'sortable' => 0,
      'separator' => '',
    ),
    'weight' => array(
      'sortable' => 0,
      'separator' => '',
    ),
    'tid' => array(
      'sortable' => 0,
      'separator' => '',
    ),
  ),
  'default' => '-1',
  'tabledrag_hierarchy' => array(
    'field' => 'tid',
    'handler' => 'taxonomy',
  ),
  'tabledrag_order' => array(
    'field' => 'weight',
    'handler' => 'taxonomy',
  ),
  'draggableviews_extensions' => array(
    'extension_top' => '3',
    'extension_bottom' => '3',
  ),
  'tabledrag_order_visible' => array(
    'visible' => 0,
  ),
  'tabledrag_hierarchy_visible' => array(
    'visible' => 0,
  ),
  'draggableviews_depth_limit' => '-1',
  'tabledrag_types_add' => 'Add type',
  'tabledrag_expand' => array(
    'expand_links' => 'expand_links',
    'collapsed' => 0,
    'by_uid' => 0,
  ),
  'tabledrag_lock' => array(
    'lock' => 0,
  ),
  'draggableviews_default_on_top' => '1',
  'draggableviews_arguments' => array(
    'use_args' => 0,
  ),
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'draggabletax');
$handler->override_option('menu', array(
  'type' => 'normal',
  'title' => 'Draggable Taxonomy',
  'description' => '',
  'weight' => '0',
  'name' => 'primary-links',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
));
welly’s picture

Hi Sevi,

Many thanks for your help, I'm using 6.x-3.2-beta5. Like I say, functionally, it's working but just with all the additional error messages. I'll try your view and see if that clears the problem. I'm sure it is most likely a small thing I've missed.

Thanks again,

Welly

welly’s picture

Great stuff, your example worked perfect. Many thanks.

itangalo’s picture

I got the same effect when using a node reference field as parent field in a draggable view. The message disappeared when I changed the field from "unlimited" values to just single value.

Pity – it spoils a great usecase. But DraggableViews is still a really neat tool. :-)

//Johan Falk, [NodeOne](http://nodeone.se), [Sweden](http://drupalsverige.se)