What Does Delta Mean in Drupal?

drupal delta

When you are adding Views, you may have seen an extra option called “Delta”.

Several students have asked us about the purpose of this field, because it wasn’t clear.

The Delta option is available throughout the site, but ordinary users are most likely to encounter it inside Views. Here’s how the “Delta” options appear in Views:

Delta option in Drupal views

And here’s how the Delta fields appear if you add them to your view. It’s really not something you’re likely to want to display.

Delta fields added to Views

So what does “Delta” mean?

“Delta” only appears fields which have multiple value. “Delta” refers to the order of the values:

  • 0 is the first item
  • 1 is the second item
  • 2 is the third item etc.

You can use Delta to restrict the results you show. For example, you might only want to show the first and third items stored in a field.

The Delta option isn’t available only in Views. With the “Image Delta Formatter” module, you can use Delta to display fields. In example below, we’re using “0,2” to only show the first and third images:

Image Delta Formatter module

If you go to the database and find the table for a field with multiple values, you’ll see that the Delta is stored here:

Delta column in Drupal database

Let’s take another example. Imagine that you have a Date field set up in Drupal 7, and you allow people to choose to repeat the date.

Repating date in Drupal

In this situation, every possible repeating date will be stored in the database, with it’s own Delta. The use of the “Delta” fields allows you choose only some of the many possible dates.

Choosing dates in Drupal usign Delta

Instructor

  • Steve is the founder of OSTraining. Originally from the UK, he now lives in Sarasota in the USA. Steve's work straddles the line between teaching and web development.

0 0 votes
Blog Rating
Subscribe
Notify of
11 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Ivan Jaros

One of my beefs with delta, since the ice age, is that it is an integer and when working with ajax, all hell breaks loose. I’m still very surprised Drupal 8 hasn’t shipped with uuids as deltas.

steve

Good point, Ivan
90% of the time, I explain Delta in this way: “This is what it is. You’ll likely never use it.”

nflowers1228

Thanks, I’ve been wondering what a delta was for the longest time. Thanks for the clear and understandable explanation.

steve

Thanks Nancy. I needed it myself. I’d often glossed over it while teaching.

Andy Read

I have worked with Drupal for 7 years and have never really liked the word delta as it’s not intuitive, even for a native english speaker. It’s actually a latin word which simply means ‘difference’ and in this context is the key that differentiates between a set of ‘objects’, items or things, often stored in a traditional PHP array.
However it is not always an integer, but in some places can be a string key, like a machine name, e.g. in the block plugin API: [url=https://api.drupal.org/api/drupal/modules%21block%21block.api.php/function/hook_block_view/7]https://api.drupal.org/api/…[/url]

steve

Thanks Andy. That’s a great point that I didn’t cover in the blog.
It doesn’t have to be a number.

Paul Booker

Very interesting. Thanks for sharing.

Acert

thanks

Fab01

Thanks for clarification. Very helpful howto!!

Hamza

Is there a difference between delta and weight?

Tommy

[quote=Ivan Jaros]One of my beefs with delta, since the ice age, is that it is an integer and when working with ajax, all hell breaks loose. I’m still very surprised Drupal 8 hasn’t shipped with uuids as deltas.bhhgbhbcfttfezsfv [/quote]

11
0
Would love your thoughts, please comment.x
()
x