When creating a new contextual filter for a view the list of types includes options such as content:spec (field_spec:delta) where spec is the name of a field I have attached to the content type accepted for the view. It appears on some, but not all of the fields offered in the list. I cannot find a reference on this field. What is this (field_name:delta)?
2 Answers
It appears only for multi-value fields. It refers to the order of the values. A delta of 0 is usually the first item, 1 is the second, etc. This can be used to restrict results to ones that have values for a specific delta.
-
2I found this really helps to reduce duplicates without using the distinct flag (which doesn't always work anyway). I have an exposed filter that can also reduce duplicates but if the filter is empty multiple results do present without
delta == 0
in the filters. Commented Jun 28, 2016 at 15:20
In Drupal, delta variable name inherits the Drupal 6 terminology and is an index for fields, blocks etc of the same type.
In module developement $delta allows one module to return many blocks. It may also be easier to understand if you keep in mind that the $delta need not be numeric. It's simply an identifier.
In your case is a local identifier of that field. It is similar to #id in CSS.
-
Thanks, I was looking for the delta in the UI, but will be meeting your variable soon as I get involved with the php end of Drupal.– AshlarCommented Oct 24, 2011 at 14:17