1

I would like to output the delta value of a multiple image field as a affix for the image title in a view, but increased with 1. So, it should start with 1 not with 0. How can I do this?

Why do I need this? I need to reference to the images from articles using the scheme Fig. 1, Fig. 2 etc. There for the view output should look like:

+----------------+
|                |
|    an image    |
|    delta 0     |
|                |
+----------------+
Fig. 1: Image Title

+----------------+
|                |
|    an image    |
|    delta 1     |
|                |
+----------------+
Fig. 2: Image Title

+----------------+
|                |
|    an image    |
|    delta 2     |
|                |
+----------------+
Fig. 3: Image Title

The first thing I tried is, to sort the view by delta and than output "Global: View result counter", but this does not work if a filter is applied to the view. If a filter is in action, the numeration would not be concordant with the delta anymore.

Do I have to write an custom formatter? And when, where do I start, I don't have an idea.

2
  • Are you not seeing the delta as a field that you can add to the view? Did you try using that and rewriting the output?
    – mpdonadio
    May 16, 2014 at 15:49
  • @MPD I know about the field, but how to rewrite the output? I want to avoid the php filter module.
    – user5950
    May 16, 2014 at 16:13

1 Answer 1

2

It depends upon what you're planning to do with that delta. Here's a possible solution for you:

Use Aggregation on the view and use "max" for the delta. Hide the field and then do a math operation to add +1 to the value of the delta.

If you could expound on the "why" it would help.

4
  • I updated my question. To use aggregation is a smart idea, but I think it would not work for my purpose (s. above).
    – user5950
    May 16, 2014 at 14:46
  • 2
    Ah! I see. My answer still stands. Just don't aggregate. Use the global math calculation and assuming you've added the delta to the field and hidden it: [delta] + 1. Caveat. Filters will mess with the numbering here too cause delta represents its position in the array of images rather than the view.
    – Rob
    May 16, 2014 at 16:57
  • You are my hero! Did not know about this field!
    – user5950
    May 16, 2014 at 17:38
  • Thanks, Rob. This did what I needed without aggregration - I simply did what was suggested in Rob's subsequent comment. The "Why" for me was to output the delta+1 as a counter on a list of items. Numbering them from 0 wasn't an option. Jul 7, 2016 at 23:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.