Hi. Was unable to find a open issue on this so here we go:

Latest Views 3 dev.
I have a image-field and try to limit the delta so it only show one of the images (the first). The view works just fine until I try to define the limit: "show 1 value - starting at 0.

Notice: Undefined index: nn in views_handler_field_field->get_items() (line 555 drupal/sites/all/modules/views/modules/field/views_handler_field_field.inc).

nn [$langcode] is the default language the site is running with. Field translation is not active and this content type does not have "Multilingual support " active.

I had a look into the code at my best ability and it looks to be this code that throws the error:

    // We are supposed to show only certain deltas.
    if ($this->limit_values) {
      $all_values = $entity->{$this->definition['field_name']}[$langcode];
      if ($this->options['delta_reversed']) {
        $all_values = array_reverse($all_values);
      }

And it is doomed to fail then there is non langcode defined in the array $this->definition['field_name']
that contain only string(15) "field_img_slide"
Removing [$langcode] also remove the error message but the imagefield it self is still missing.

from line 574:

if (isset($all_values[0][$new_delta])) {
          $new_values[] = $all_values[$new_delta];
}

This code never validate and $new_value array is returned empty. It is getting late so I'm stopping my quest for today, tired so I could be barking up the wrong tree here.

Best regards
Steinmb

Comments

dawehner’s picture

$entity->{$this->definition['field_name']}[$langcode];

This line is causing the notice.

For field_name = 'field_body' it's $entity->field_body[$langcode].

So the problem is that your entity doesn't have the specific field on it.

But if you look up some lines you see this code

    if (empty($entity->{$this->definition['field_name']})) {
      return array();
    }

So this is all very strange.

Can you describe a way to reproduce the problem?

mathieuhelie’s picture

Sorry for the hijack but can you describe what feature of Views 3 allows filtering out images to the first delta? A straight filter no longer seems to work.

edit;
This was actually a bug and you must run DEV of Views to use this feature.

#1017128: No way to render a single delta of a multivalue field

steinmb’s picture

Hmm this is a clean D7.0 installation, nothing special really.
I have a local installation sandboxed snapshot of the site before I created the view. I might try and reproduce it on this.

Could i18n have done some funky stuff perhaps? I mean does every field have [$langcode] attached to them?

@mathieuhelie It is not a filter, you define this on the field you use in the view.

metalinspired’s picture

Hi. Same problem here.
I'm fairly new to Drupal and after dumping some variables I found that images are language independent and that seems to cause the problem.
Here's what I did to solve the problem but someone with more knowledge on developing for Drupal (I have almost none for now :D ) should change this not to use hard coded values.
In views_handler_field_field.inc changed line 555 from
$all_values = $entity->{$this->definition['field_name']}[$langcode];
to
$all_values = $entity->{$this->definition['field_name']}['und'];
and on line 580 from
$entity->{$this->definition['field_name']}[$langcode] = $new_values;
to
$entity->{$this->definition['field_name']}['und'] = $new_values;

Edit: This only worked for dummy content created by Devel module. Not a valid fix!!!

dawehner’s picture

Status: Active » Postponed (maintainer needs more info)

langcode should contain the right language.

@steinmb

Can you describe the setup to reproduce the problem?

steinmb’s picture

Devel module? Waaaait a minute, my content is also created by the devel module. Manually created a node and the delta setting actually workes just fine! So it is a but in the devel module then?

This site is running with only one language enabled (nn), still devel module managed to create language neutral (the array is not keyed with the active language (nn) but with "und") nodes? Hell multilingual support is even off on the content type views failed on. @dereine I might have wasted your time on this, sorry.

--
Stein, still pining for the fjords

dawehner’s picture

Status: Postponed (maintainer needs more info) » Fixed

As long the issue is fixed i'm fine ;)

steinmb’s picture

Project: Views (for Drupal 7) » Devel
Version: 7.x-3.x-dev » 7.x-1.0
Component: fieldapi data » devel_generate
Status: Fixed » Active

Hi
Turned out that this bug might belong to you guys?

chup’s picture

Problem is not fixed!
I have this problem with myself-created nodes. After enabling second language all the images (through the field) dissapeared and I have same notice error.

steinmb’s picture

@chup: Nones have ever claimed it is ;)
I'm still waiting for any of the maintainers to pick up this issue.

moshe weitzman’s picture

Title: Unable to define delta on multifileld » Fields are always marked as language independent
Status: Active » Fixed

Fixed. if you have a single enabled language, your nodes will now be marked with that language. if you have multiple languages, use the --languages option to specify.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.