I see there is native handler for hierarchy but the Field API handler is missing. Are there any plans to add this? Can this be done simply by copying and a bit adjusting the Field API handler for sorting?

Comments

istryker’s picture

Category: task » feature

Patches welcome

hellolindsay’s picture

I very much want this feature too. I also might be willing to do the work. I am very familiar with Drupal's guts but not with this module nor with hooking into views. I am up to the challenge if someone with DraggableViews development experience can point me in the right direction.

In the 20 mins I just spent looking into this:

  • I can tell that I will need to create handlers/draggableviews_hierarchy_handler_fieldapi.inc.
  • I suspect that I can hack together a working version by looking at draggableviews_handler_fieldapi.in and draggableviews_handler_native.inc.
  • I have managed to get "FieldAPI" to appear as an option for Hierarchy Handler. I have not been able to get additional form options to appear when it is selected though.

My specific questions are:

  • Are there other files that I will need to modify?
  • Should I be able to get FieldAPI form options to appear for Hierarchy Handler by modifying draggableviews_hierarchy_handler_fieldapi.inc alone?

I've attached my very-basic draggableviews_hierarchy_handler_fieldapi.inc in case it helps. It was created by duplicating draggableviews_handler_fieldapi.inc and replacing "_handler" with "_hirearchy_handler".

Pointers appreciated.

istryker’s picture

hi hellolindsay,

You are correct, we will need to create handlers/draggableviews_hierarchy_handler_fieldapi.inc. I took a stable at this, and didn't get too far. The main reason is I didn't know where to store the parent information.

How Native and Core Taxonomy does this
Native:
2 Columns in the database, weight & parent. Both are in the draggableviews_structure table.
Taxonomy:
2 Columns in the database, weight & parent. Weight stored in taxonomy_term_data table, Parent in taxonomy_term_hierarchy table.

How the values are stored in the database are different. I would like them to be the same. I am working on this. You don't need to look at this now, but if you want to see #1906454: Change Native Handler organization to how Taxonomy does it

How FieldAPI works:
1 Column in the database, value [actually the column is 'field_X_value', where X in the name of the field]. Table name is field_data_X, where X is the name of the field.

So where is the parent? Do we use 2 fields?
I do not see us adding another column to the field_data_X column, as I do not know how we can track this and track when the field is deleted.
I do not see us changing the integer value to a string/array so we can do something like this 'weight:parent' or array('weight' => X, 'parent' => Y) as this will break the data type of the field.

The next issue, how should the UI of the Draggbleviews field look like and its workflow. IMO this next issue minor, and should only be solved after the main issue is solved.

hellolindsay’s picture

My vote:
Don't modify any tables. Store weight in one field (field_mynode_weight_value) and Parent in another field (field_mynode_parent_value). So:

For the Weight:
Store the weight value in any field of type Integer using FieldAPI. This already works.

For the Parent:
Simply store the parent value in any other field of type Integer using FieldAPI.

istryker’s picture

That is the only way I see it working too.

Ok, the next question, how do we do this?
So currently we add a draggableviews content field. We select FieldAPI for the sort handler, then we select the field. This needs to be extended for hierarchy, where we will select FieldAPI as the hierarchy handler, then select the field.

Believe this is done in function options_form() the new handlers/draggableviews_handler_hierarchy_fieldapi.inc file.

Also you might to change the the code below, which adds the parent field. You will find this at the bottom of views/draggableviews_join_handler.inc in latest 7.x-2.x dev.

   // Add also parent field.
    if ($order_view = _draggableviews_load_order_view($view)) {
      if (isset($order_view->field['draggableviews']->options['draggableviews']['hierarchy_handler'])
        && $order_view->field['draggableviews']->options['draggableviews']['hierarchy_handler'] == 'draggableviews_hierarchy_handler_native') {
        $select_query->addField($table['alias'], 'parent', 'draggableviews_structure_parent');
      }
    }

you just need to add the correct field, just like the native has done.

hellolindsay’s picture

Ok, that's a good primer. I'll see what I can do.

thesame-’s picture

I created this taxonomy term hierarchy handler. It works fine. It works best with http://drupal.org/node/1716912 because it doesn't use any sort handlers so http://drupal.org/project/taxonomy_edge can be used for sorting. Default taxonomy weight sorting fails because deeper level terms might have (and most likely will) have the same weights as parents.

One thing tought...

My handler doesn't run before "draggableviews_preprocess_views_view_table(&$vars) " has been altered.

This code is not walidating:

if ($order_view = _draggableviews_load_order_view($vars['view'])) {

as there is no need for draggableviews_handler_sort.

What I did to test my handle is I duplicated this code before if statement:


$order_view = $vars['view'];

if (!empty($order_view->field['draggableviews']->options['draggableviews']['hierarchy_handler'])) {
      $hierarchy_handler_object = draggableviews_get_handler_class($order_view->field['draggableviews']->options['draggableviews']['hierarchy_handler'], 'hierarchy_handler');
      foreach ($vars['rows'] as $key => $row) {
        $first_column = current(array_keys($row));
        $field = (object) array('view' => $vars['view']);
        $depth = $hierarchy_handler_object->get_depth($field, $key);
        $vars['rows'][$key][$first_column] = theme('indentation', array('size' => $depth)) . $vars['rows'][$key][$first_column];
        $vars['row_classes'][$key][] = 'depth-' . $depth;
      }
    }

BUT THIS IS ONLY FOR TESTING HANDLER!

These changes shouldn't be made as permanent.
Ill need some help to figure out some good solution for this.

In my opinion this part shouldn't be depending on any sorts as it handles only depth.

hellolindsay’s picture

Hi thesame, please open a new issue for your taxonomy term handler.

istryker’s picture

@thesame I agree with hellolindsay, issue #1716912: Add a taxonomy term weight handler is for taxonomy handler. This issue is for fieldapi hierarchy handler. You may create a new issue for taxonomy hierarchy handler if #1716912 does not do it.

hellolindsay’s picture

I am stuck on something. Here is an example to demonstrate:

Let's say I wanted to add a new field to the options form. Inside of views/draggableviews_handler_field_draggable.inc, at the bottom of the options_form() function, there is a text field that is already part of the options form - the "Custom save button label" text field - here is the already-existing code for that field:

 // this code already exists in draggableviews_handler_field_draggable.inc
$form['draggableviews']['save_button_label'] = array(
      '#type' => 'textfield',
      '#title' => t('Custom Save button label'),
      '#size' => 20,
      '#description' => t("Allow to change Save button Label."),
      '#default_value' => $this->options['draggableviews']['save_button_label'],
 ); 

Now, if I want to add another text field just like this one, I can add some new code, like this:

 // this code already exists in draggableviews_handler_field_draggable.inc
$form['draggableviews']['save_button_label'] = array(
      '#type' => 'textfield',
      '#title' => t('Custom Save button label'),
      '#size' => 20,
      '#description' => t("Allow to change Save button Label."),
      '#default_value' => $this->options['draggableviews']['save_button_label'],
 );
// new code starts here
$form['draggableviews']['new_field'] = array(
      '#type' => 'textfield',
      '#title' => t('New field'),
      '#size' => 20,
      '#description' => t("This is a new field."),
      '#default_value' => $this->options['draggableviews']['new_field'],
 );

If I add this new code and save the file, the new field appears as expected. The options form now shows "Custom Save button label'" followed by "New field".

Here's the problem: The new field's value will not be saved. If I type "This is some text" into the new field and click "Apply", the field will be empty next time I open the options form.

What am I missing? Is there code somewhere else in the module that is responsible for saving field values? Advice appreciated.

Note: This is a demonstration. I will not really be adding a new text field, nor will I be editing draggableviews_handler_field_draggable.inc. Really, I am trying to save the value of the new select list in handlers/draggableviews_hierarchy_handler_fieldapi.inc - so far, no luck. If you can help with the above example, though, then I should be able to take it from there.

istryker’s picture

After @hellolindsay comment I tried to figure this out too. I believe I ran into the same problems. The hierarchy field would show up correctly, but after save & reload the setting was gone.

I figured it out. See code below.

  // From views/draggableviews_handler_field_draggable.inc
  // ...
  // ...
  function option_definition() {
    $options = parent::option_definition();

    $options['draggableviews'] = array(
      'contains' => array(
        'handler' => array('default' => 'draggableviews_handler_native'),
        'hierarchy_handler' => array('default' => ''),
        'save_button_label' => array('default' => 'Save'),
        'ajax' => array('default' => FALSE),
      ),
    );

    // Populate default values of form elements provided by handlers.
    foreach (draggableviews_get_handlers() as $handler_id => $handler_object) {
      $options['draggableviews']['contains'][$handler_id] = array('default' => $handler_object->option_definition());
    }
+    foreach (draggableviews_get_hierarchy_handlers() as $handler_id => $handler_object) {
+      $options['draggableviews']['contains'][$handler_id] = array('default' => $handler_object->option_definition());
+    }
    return $options;
  } 
  // ...
  // ...

So the default values of all the heirarchy_handlers were not getting populated.

FYI - I do not understand why its ['contains'] array. This must be a Views thing. Inside views/draggableviews_handler_field_draggable.inc function option_forms(), this is how you access the default value. $this->options['draggableviews'][$handler_id]['field'] (where $handler_id = draggableviews_hierarchy_handler_fieldapi)

hellolindsay’s picture

@iStryker is exactly right. New fields are saving for me too now. Nice work.

istryker’s picture

FYI - This might change some things. This patch, draggableviews-remove_php5_4_strict_warning-191416-4.patch, from #1914166: PHP 5.4 Strict warning, will probably get committed.

This will more that likely change this issues solution (hopefully make it easier).

joel_osc’s picture

Just wondering what the status is on getting a FieldAPI handler in for hierarchy? This would be a fantastic feature.

hellolindsay’s picture

Unfortunately I have not been able to work on this recently. I agree that it is a very needed feature. For now I have used a less-perfect drag-and-drop solution so that I can continue with the project I am working on. I may come back to this issue later, I will post here again before I do. Feel free to pick this one up anyone!

dobe’s picture

I just started working on this issue as I need this functioning for both Parent Entities nodes/taxonomy situations. I have ran into something that I am having a hard time tracking down.

Everything for hierarchy is working fine. I am getting the options to save the the draggableviews_structure table etc. However if I want to save the fields data as well using the

function set($form_state) { } within draggableviews_hierarchy_handler_fieldapi.inc If I do a "dsm($form_state);" within that function I get nothing back. The only way it outputs is when I use dsm the set function within draggableviews_handler_native.inc. This is weird because I thought that the it would at least do it in draggableviews_hierarchy_handler.inc but that is not the case.

Look at my attachment.

dobe’s picture

Seems like my issue may be due to this issue that I commited a patch to. Maybe it will progress the fieldapi side of the draggable hierarchy's

http://drupal.org/node/1995110#comment-7413522

dobe’s picture

Well. I think I have finally made some progress on this issue. After digging into this module I have learned quite a bit of how it is setup and it made me do some things in this patch that are obviously not a "fixall" but the approach to some of the logic seems more understandable.

One of the main things that this patch does is removes the DraggableViews fields dependencies on sorts for the Fieldapi side of things. So now when creating a DraggableView that uses the Fieldapi it determines the fields used for the weight and parent based on other "fields" added to the view instead of "sorts" this also supports entity reference fields for parents.

So basically when setting up a DraggableView you will do:

1) Add parent and weight fields
2) Add Draggableviews content field
3) Add Draggableviews weight sort

Interested in feedback. I have some other things that need to be addressed in this module however those are for a different queue and day.

**note** this patch includes patch found at http://drupal.org/node/1995110#comment-7413522

-Jesse

Jujens’s picture

Issue summary: View changes

This last patch worked for me. Thanks.

joel_osc’s picture

This patch seems to work great, thank-you very much for putting the effort into this! I will continue testing as we roll this functionality into an internal site and let you know if I find anything. I am curious what you would recommend if we would like to display each level as indented? I figure we should be able to attach a css class such as 'dv-indent-1' to each row to mark a 'level' in the hierarchy, but I am not 100% sure where this functionality should reside.

Again, thank-you!

heivoll’s picture

Tried the patch in #19 and it works, except for one issue; If there is an inconsistency between the entity's language and the parent field's language, it will not work. I've tried to fix this by using entity_metadata_wrapper() to handle getting the values from the View, but obviously this is a little less effective. So if anyone wants to improve this, go ahead! In any case, here's a patch that is the one from #19 and my changes.

socialnicheguru’s picture

Status: Active » Needs work

against latest dev version 2/5/15
https://www.drupal.org/node/1353808

patch -p1 < draggableviews-hierarchy-fieldapi-additions-1879408-22.patch
patching file draggableviews.info
Hunk #1 FAILED at 4.
1 out of 1 hunk FAILED -- saving rejects to file draggableviews.info.rej
patching file draggableviews.module
Hunk #2 FAILED at 100.
1 out of 2 hunks FAILED -- saving rejects to file draggableviews.module.rej
patching file handlers/draggableviews_handler.inc
patching file handlers/draggableviews_handler_fieldapi.inc
Hunk #1 FAILED at 29.
Hunk #2 FAILED at 69.
Hunk #3 succeeded at 103 (offset -4 lines).
2 out of 3 hunks FAILED -- saving rejects to file handlers/draggableviews_handler_fieldapi.inc.rej
patching file handlers/draggableviews_hierarchy_handler.inc
patching file handlers/draggableviews_hierarchy_handler_fieldapi.inc
patching file views/draggableviews_handler_field_draggable.inc
patching file views/draggableviews_handler_sort.inc
patching file views/draggableviews_join_handler.inc
Hunk #2 FAILED at 24.
1 out of 2 hunks FAILED -- saving rejects to file views/draggableviews_join_handler.inc.rej

istryker’s picture

Patch needs to be re-roll, attached is the 'git apply -v' output. This should help someone reroll it.

istryker’s picture

clemens.tolboom’s picture

I tried to reroll the patch but failed to solve the conflicts. Here is what I did resulting in a whitespace + indentation problem free version I hope.

According to #22 the patch was created from version = "7.x-2.0+56-dev" so I ended up with commit 4f5ac4ca6eaef98d9ccf28b715eeaa2548306ccd

git checkout 4f5ac4ca6eaef98d9ccf28b715eeaa2548306ccd
git checkout -b feature/1879408
git apply draggableviews-hierarchy-fieldapi-additions-1879408-22.patch
git add handlers/draggableviews_hierarchy_handler_fieldapi.inc
git commit -am "#22"

Clean up whitespace mess

git diff 4f5ac4ca6eaef98d9ccf28b715eeaa2548306ccd

The patch works like a charm.

clemens.tolboom’s picture

[edit]deleted[/edit]

clemens.tolboom’s picture

Status: Needs work » Needs review
StatusFileSize
new28.51 KB

I did a reroll based on #26 which went OK.

Notice: Undefined variable: hierarchy_handler in draggableviews_preprocess_views_view_table() (line 156 of /.../modules/draggableviews/draggableviews.module).

Now sure why this happens :-(

clemens.tolboom’s picture

Issue summary: View changes
StatusFileSize
new30.81 KB
new18.83 KB
new18.75 KB

Did another reroll based on #22 left out the whitespacefix and just rerolled to latest dev. That worked. See below

Note the change in Parent colomn which is a field for task

istryker’s picture

Getting errors

Notice: Trying to get property of non-object in draggableviews_hierarchy_handler_fieldapi->get_depth() (line 158 of /var/www/drag7/sites/all/modules/contrib/draggableviews/handlers/draggableviews_hierarchy_handler_fieldapi.inc).

clemens.tolboom’s picture

Issue summary: View changes
StatusFileSize
new27.11 KB
new3.28 KB
new33.16 KB

Patch needed a reroll (or my own git version :-/

I added my feature using task module. Create some tasks. Hope that helps.

clemens.tolboom’s picture

Worth to mention is as task:parent is an editable item it's possible to create recursion break the view.

- Add task 1
- Add task 2; set parent to task 1
- Edit task 1; set parent to task 2

It's worth an issue but please lets not hold this issue as field permissions module can prevent this.

PascalAnimateur’s picture

Re-rolled patch against latest dev...

PascalAnimateur’s picture

PascalAnimateur’s picture

PascalAnimateur’s picture

StatusFileSize
new27.64 KB

Finally I think this one's ok (sorry about that)

clemens.tolboom’s picture

I cannot find time to test this but patch has

  1. +++ b/handlers/draggableviews_handler.inc
    @@ -51,4 +51,29 @@ class draggableviews_handler {
    +  public function field_info($field_option) {
    +	// Get the name of selected field.
    +    list($field_table, $field_name) = explode(':', $field_option);
    +
    +	$field_info_field = field_info_field($field_name);
    +
    +	reset($field_info_field['columns']);
    +	$column = key($field_info_field['columns']);
    +
    +	$field_info = array(
    +	  'table' => $field_table,
    +	  'name' => $field_name,
    +	  'type' => $field_info_field['type'],
    +	  'column' => $column,
    +	);
    +
    +	return $field_info;
    

    White space (tabs?)

  2. +++ b/handlers/draggableviews_handler.inc
    @@ -51,4 +51,29 @@ class draggableviews_handler {
    \ No newline at end of file
    

    No EOL

semanthis’s picture

I applied patch from #36 against latest dev.

This is what I get if I try to reorganise hierarchy:

Warning: reset() expects parameter 1 to be array, string given in EntityListWrapper->set() (line 1053 of /.../sites/all/modules/entity/includes/entity.wrapper.inc).
EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. in EntityMetadataWrapper->set() (line 122 of /.../sites/all/modules/entity/includes/entity.wrapper.inc).

Does anyone have an idea what could be wrong about my setting? Any help would be appreciated.

View-export looks like this:

$view = new view();
$view->name = 'themen_sortieren';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Themen sortieren';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Themen sortieren';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'none';
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['columns'] = array(
'title' => 'title',
'field_uebergeordnetes_thema' => 'field_uebergeordnetes_thema',
'draggableviews' => 'draggableviews',
);
$handler->display->display_options['style_options']['default'] = '-1';
$handler->display->display_options['style_options']['info'] = array(
'title' => array(
'sortable' => 0,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'field_uebergeordnetes_thema' => array(
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'draggableviews' => array(
'align' => '',
'separator' => '',
'empty_column' => 0,
),
);
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
/* Field: Content: Übergeordnetes Thema */
$handler->display->display_options['fields']['field_uebergeordnetes_thema']['id'] = 'field_uebergeordnetes_thema';
$handler->display->display_options['fields']['field_uebergeordnetes_thema']['table'] = 'field_data_field_uebergeordnetes_thema';
$handler->display->display_options['fields']['field_uebergeordnetes_thema']['field'] = 'field_uebergeordnetes_thema';
$handler->display->display_options['fields']['field_uebergeordnetes_thema']['label'] = '';
$handler->display->display_options['fields']['field_uebergeordnetes_thema']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_uebergeordnetes_thema']['type'] = 'entityreference_entity_id';
$handler->display->display_options['fields']['field_uebergeordnetes_thema']['settings'] = array(
'link' => 0,
);
$handler->display->display_options['fields']['field_uebergeordnetes_thema']['delta_offset'] = '0';
/* Field: Content: Untergeordnetes Thema */
$handler->display->display_options['fields']['field_untergeordnetes_thema']['id'] = 'field_untergeordnetes_thema';
$handler->display->display_options['fields']['field_untergeordnetes_thema']['table'] = 'field_data_field_untergeordnetes_thema';
$handler->display->display_options['fields']['field_untergeordnetes_thema']['field'] = 'field_untergeordnetes_thema';
$handler->display->display_options['fields']['field_untergeordnetes_thema']['label'] = '';
$handler->display->display_options['fields']['field_untergeordnetes_thema']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_untergeordnetes_thema']['type'] = 'entityreference_entity_id';
$handler->display->display_options['fields']['field_untergeordnetes_thema']['settings'] = array(
'link' => 0,
);
$handler->display->display_options['fields']['field_untergeordnetes_thema']['delta_offset'] = '0';
/* Field: Draggableviews: Content */
$handler->display->display_options['fields']['draggableviews']['id'] = 'draggableviews';
$handler->display->display_options['fields']['draggableviews']['table'] = 'node';
$handler->display->display_options['fields']['draggableviews']['field'] = 'draggableviews';
$handler->display->display_options['fields']['draggableviews']['label'] = '';
$handler->display->display_options['fields']['draggableviews']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['draggableviews']['element_default_classes'] = FALSE;
$handler->display->display_options['fields']['draggableviews']['hide_alter_empty'] = FALSE;
$handler->display->display_options['fields']['draggableviews']['draggableviews']['hierarchy_handler'] = 'draggableviews_hierarchy_handler_fieldapi';
$handler->display->display_options['fields']['draggableviews']['draggableviews']['ajax'] = 0;
$handler->display->display_options['fields']['draggableviews']['draggableviews']['draggableviews_hierarchy_handler_fieldapi'] = array(
'field' => 'field_data_field_uebergeordnetes_thema:field_uebergeordnetes_thema',
);
/* Field: Draggableviews: Parent */
$handler->display->display_options['fields']['parent']['id'] = 'parent';
$handler->display->display_options['fields']['parent']['table'] = 'draggableviews_structure';
$handler->display->display_options['fields']['parent']['field'] = 'parent';
$handler->display->display_options['fields']['parent']['separator'] = '';
/* Field: Draggableviews: Weight */
$handler->display->display_options['fields']['weight']['id'] = 'weight';
$handler->display->display_options['fields']['weight']['table'] = 'draggableviews_structure';
$handler->display->display_options['fields']['weight']['field'] = 'weight';
/* Field: Content: Nid */
$handler->display->display_options['fields']['nid']['id'] = 'nid';
$handler->display->display_options['fields']['nid']['table'] = 'node';
$handler->display->display_options['fields']['nid']['field'] = 'nid';
/* Sort criterion: Draggableviews: Weight */
$handler->display->display_options['sorts']['weight']['id'] = 'weight';
$handler->display->display_options['sorts']['weight']['table'] = 'draggableviews_structure';
$handler->display->display_options['sorts']['weight']['field'] = 'weight';
$handler->display->display_options['sorts']['weight']['draggableviews_setting_view'] = 'themen_sortieren:page';
$handler->display->display_options['sorts']['weight']['draggableviews_parent_field'] = 'field_data_field_uebergeordnetes_thema:field_uebergeordnetes_thema';
$handler->display->display_options['sorts']['weight']['draggableviews_setting_new_items_bottom_list'] = 1;
/* Sort criterion: Content: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'node';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
'themen' => 'themen',
);

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'themen-sortieren';

semanthis’s picture

Ok found the mistake I made: I changed formatter of entityreference field in the view to output the id instead of the label. Changing the formatter back to default solved it. However, I can't dig too deep into that issue, but it shouldn't be to hard to fix that. Thank You for your great work!

niallmurphy-ie’s picture

A new dev has been released and the patch fails.. Could someone post the older dev or reroll the latest patch please?

Really interested in this functionality.

Thanks.

et.cetera’s picture

Hi,

I applied the patch to the latest dev and it applied except some lines (you can get them from the '.rej' file which is then created) cleanly. I would do a reroll but I don't know how to do a proper p1 patch.

It was some kind of hard to figure out after patching what to do now, since the information in this issue is some kind of mixed up. What worked for me:

1) Create a reference and a weight field (must be of type int!) for your entity
2) Create a view in table format and add the Draggableviews: Content field. Select Sort and Hierarchy handler Field API and choose the fields created in 1).
3)In sort select the draggableviews sort by weight, where you again choose your fields from 1).

What does not work for me:
- If I select native sort in 2). This gives me from time to time a 500 internal server error (I guess because the reference field is filled sometimes incorrectly and irrational). But otherwise arguments are working and are stored in the draggableviews_structure table.
- Storing arguments in 3) does not work when using Field API for sort and hierarchy. Normally the weight info, parent and arguments are stored in the draggableviews_structure table. Now with using the Field API the information is stored in the 'field_data_fieldname' tables, which of course does not provide a space to store the argument information anywhere, since we only have a field for the parent reference and the weight, whereas the the draggableviews_structure table does not seem to be used anymore. I don't know if the argument handling is treated in the patch code, maybe it just does not work for me...

Would love to see this in 2.2....

merauluka’s picture

Rerolled #36 against latest dev. (7.x-2.1+9-dev)

Status: Needs review » Needs work

The last submitted patch, 42: draggableviews-fieldapi-handler-1879408-42-7.x.patch, failed testing.

merauluka’s picture

This patch failed because the dev branch has currently failed testing. Requeuing for a time when the dev branch is ready.

ConradFlashback’s picture

Two problem:
- Error: Notice: Trying to get property of non-object in draggableviews_hierarchy_handler_fieldapi->get_depth() (line 158
- When I save the first time it seems to work (with the error message). But at the second save it delete the content of my custom hierarchy field.

marceldeb’s picture

subscribing...

murz’s picture

@ConradFlashback, did you succesfully apply a patch to current dev version? Or which release did you use?

ConradFlashback’s picture

@Murz I tried with 7.x 2.1 and also with dev online on july.
I will try soon with a new project test, because I can't remember where I used this 6 month ago ;)

murz’s picture

O can't apply patch from #42 on last release:

 git apply ../draggableviews-fieldapi-handler-1879408-42-7.x.patch
error: patch failed: handlers/draggableviews_handler_fieldapi.inc:102
error: handlers/draggableviews_handler_fieldapi.inc: patch does not apply
error: patch failed: handlers/draggableviews_hierarchy_handler_native.inc:21
error: handlers/draggableviews_hierarchy_handler_native.inc: patch does not apply

and on current git version too:

git apply ../draggableviews-fieldapi-handler-1879408-42-7.x.patch
error: patch failed: handlers/draggableviews_handler_fieldapi.inc:29
error: handlers/draggableviews_handler_fieldapi.inc: patch does not apply
murz’s picture

Status: Needs work » Needs review
StatusFileSize
new21.21 KB

I apply this patch manually with replace changes in current git version of draggableviews, here is re-rolled patch - please review it.

Status: Needs review » Needs work

The last submitted patch, 50: draggableviews-fieldapi-handler-1879408-50-7.x.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

firewaller’s picture

The path in #50 applies cleanly for me in 7.x-2.1+16-dev, but when I go to my draggableview I don't see the FieldAPI option under "Hierarchy handler". Is there a hook or something I should be adding to have it show up?

gravisrs’s picture

The patch in #50 also applies cleanly for me in 7.x-2.1+16-dev

But creating the view when I put entityreference field (parent) into fields and weight (number) into fields and sort - I cannot setup them in Draggableviews:content field.

It shows me to select FieldAPI for sorting handler but then I cannot select my sorting field from the list (list is empty)
It doesn't show me FieldAPI under hierarchy selection - only Native handler there.

All modules in latest stable versions (except draggableviews):

drupal: 7.67
views: 7.x-3.23
entity: 7.x-1.9
entityreference: 7.x-1.5
draggableviews: 7.x-2.1+16-dev + patch #50 here

So apparently something broke.