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

Author

  • Steve Burge

    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
Article Rating
Subscribe
Notify of
11 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Ivan Jaros
Ivan Jaros
8 years ago

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
steve
8 years ago
Reply to  Ivan Jaros

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
8 years ago

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

steve
steve
8 years ago

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

Andy Read
Andy Read
8 years ago

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
steve
8 years ago
Reply to  Andy Read

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
Paul Booker
8 years ago

Very interesting. Thanks for sharing.

Acert
Acert
7 years ago

thanks

Fab01
Fab01
7 years ago

Thanks for clarification. Very helpful howto!!

Hamza
Hamza
6 years ago

Is there a difference between delta and weight?

Tommy
Tommy
4 years ago

[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