Hi guys,

While working on displaying fields with multiple values, I did a few tests with the options available under the Multiple Field Settings.
More particularly, when Display all values in the same row is selected:

  • Display 'all'/N value(s) - delta_limit
  • starting from - delta_offset
  • Reversed - delta_reversed
  • First and last only - delta_first_last

 
Screenshot of an Image Field, Multiple Field Settings form, with the Reversed and Limit options highlighted: Limit is set to 'all' and Reversed is checked.
 Limit is set to 'all' and Reversed is checked.

Problem: Currently, when the number of items to display is set to all, Reversed is ignored.

I found unexpected to see that enabling Reversed with the default to 'all' wouldn't make any difference: items wouldn't be reversed.
Even more surprising, I found that if the limit was set to 1000 (or any very large number) "all" items would be properly reversed.

I'm not sure exactly if there would be any particular reason why items shouldn't be reversed when 'all' would be selected as the limit, but I would assume it might be a bit confusing to users (was that a "security" measure, in terms of performance not to allow applying array_reverse to a too large array?)
In particular, since nothing is specified and everything seems to work fine (as expected) when any other options are used with limit 'all', for example, offset or first/last (it does change the display of the results after settings are saved).

I was wondering if this is a change that you could potentially consider as acceptable.
Personally, I wouldn't necessarily see any issue if all field values could be reversed, especially since they could already be reversed by providing a very large limit (but not for 'all').

Please let me know if you would have any questions, objections, comments, suggestions, recommendations or concerns on any aspects of this issue, I would be glad to provide more information or explain in more details.

Any questions, feedback, testing, changes, ideas or recommendations would be highly appreciated.
Thanks to all in advance.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DYdave’s picture

Quick follow-up on this issue:

Please find attached to this comment a patch against views-7.x-3.x at 22bf853 that should allow Multiple Field Settings 'all' values to be displayed in Reversed order.
File attached as: views-display-all-reversed-values-2070313-1.patch

The patch changes the check/if in file views_handler_field_field.inc, line 761:

<?php
    if ($this->limit_values && !empty($entity->{$this->definition['field_name']})) {
?>

into:

<?php
    if (($this->limit_values || $this->options['delta_limit'] == 'all') && !empty($entity->{$this->definition['field_name']})) {
?>

 

This patch has been tested and seems to work as expected, but I would greatly appreciate to have your feedback, questions, comments, reviews, suggestions, recommendations, improvements and testing for this patch.

Feel free to let me know if you would have any further comments, issues, questions, objections, recommendations, suggestions, testing, reporting or concerns on the attached patch or any other aspects of this ticket in general, I would be glad to provide more information or explain in further details.

Thanks in advance to all for your feedback, reviews, testing and reporting.
Cheers!

crutch’s picture

I just ran into this issue where multiple images where being uploaded and they should be displayed in reverse order so the maintainer doesn't have to reorder manually. I used the immediate temporary fix on live sites for relief by using a value instead of "all" in the View Pane.

Testing this patch in development fixes the issue and will be applying to all live sites. Thank you.

Anonymous’s picture

Hello everyone
The above patch has been tested and is working correctly .
Hence is successful in reversing the order of text for multiple values in view.

Anonymous’s picture

DYdave’s picture

Thanks a lot guys for your feedbacks on this patch... after 4 years, I had kinda forgotten about it :)
Glad I documented it with more details so others could use it.

Hopefully, ticket will get some attention from maintainers who will provide further reviews.

Feel free to let me know if you encounter any issues with the patch, I would be glad to reply and provide more information.

Thanks again for all your reviews, testing and reporting.
Cheers!

Anybody’s picture

+1 for RTBC.

nithinkolekar’s picture

+1 RTBC for all value, which is the actual issue.

As per OP

I found that if the limit was set to 1000 (or any very large number) "all" items would be properly reversed.

which works even without this patch but reverse is still ignored if multivalue max is set to static value in field instance settings. I tested with simple gallery with limited of 25 images per gallery.
views config screen:
2070313-mulitivalue-static-cordinality-reverse

could we append "all' option to selection element here & let it go through same logic in the above patch?

nithinkolekar’s picture

tried appending 'all' option to selection list which works fine.
But not sure whether its a right Drupal way

-$options = drupal_map_assoc(range(1, $field['cardinality']));
+$options = drupal_map_assoc(range(1, $field['cardinality'])) + array("all"=>t("all"));

(code ref https://drupal.stackexchange.com/questions/3590/adding-an-all-option-to-...)