These notices are thrown when I choose "Content page: Tags Field" for one Selection Rule in my Variants.

Notice: Undefined index: module in ctools_entity_field_value_ctools_access_summary() (line 213 of /home/content/68/9050068/html/drupal/sites/all/modules/ctools/plugins/access/entity_field_value.inc).
Notice: Undefined variable: elements in ctools_entity_field_value_ctools_access_summary() (line 220 of /home/content/68/9050068/html/drupal/sites/all/modules/ctools/plugins/access/entity_field_value.inc).

It is my understanding that I should be able to use this choice to select pages based on taxonomy term tags. Please help.

Update:
I just got a second set of errors when I tried to do something similar on another Variant

# Notice: Undefined index: value in _ctools_entity_field_value_ctools_access_get_conf_field_values() (line 172 of /home/content/68/9050068/html/drupal/sites/all/modules/ctools/plugins/access/entity_field_value.inc).
# Notice: Undefined index: value in ctools_entity_field_value_ctools_access_check() (line 155 of /home/content/68/9050068/html/drupal/sites/all/modules/ctools/plugins/access/entity_field_value.inc).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tlarrieu’s picture

Title: Notices thrown when » Notices thrown when taxonomy used for selection criteria

It looks like the problem is related to the code on those lines looking for array key 'value' when it should be looking for the array key 'tid' for taxonomy. A quick test of changing lines from

155: if (in_array($field_value['value'], $conf_value_array)) {
172: $conf_values[] = $value['value'];

to

155: if (in_array($field_value['tid'], $conf_value_array)) {
172: $conf_values[] = $value['tid'];

Makes the error go away and the taxonomy selection rule works correctly. Of course this is just a data point and not a fix, because it breaks the selection rule for non-taxonomy criteria. A proper fix will need to account for both cases.

quinn.mckinsey’s picture

Patch for this problem.

Applies to ctools-7.x.1.0

Instructions of what to look for:
On one of the content types, for instance articles, add a field called "my tag field" that is of type "Term Reference".
In page manager, choose a variant. Under the Contexts tab, add a "taxonomy vocabulary" or "taxonomy term" to the contexts list. Under the Selection rules tab, choose "Node page: my tag field" and select one of the taxonomy terms. The variant now applies to all articles with the selected taxonomy term in the "my tag field" of the article.

Details for programmers:
Modified "Check field value" section of ctools_entity_field_value_ctools_access_check function to account for 'tid' as a possible key in field_value array. This array now accepts 'value' and 'tid' as possible keys, and an Exception is thrown in all other cases.
Modified "Set conf_values" section of _ctools_entity_field_value_ctools_access_get_conf_field_values function to account for 'tid' as a possible key in value array. This array now accepts 'value' and 'tid' as possible keys, and an Exception is thrown in all other cases.

Personal Notes:
I'm not sure if this patch represents the correct way to fix this problem. It hinges on ctools being aware of 'tid' key, which I'm not sure if ctools provides or if another module provides. However, I figured any solution is better than no solution. Feedback is appreciated.

quinn.mckinsey’s picture

Status: Active » Needs review

Changing status to needs review.

Kars-T’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
FileSize
1.49 KB

Hi

I did reroll the patch agains latest 7.x branch so that it doesn't use tabs and applies to the coding standard.

Otherwise we use this patch in a project and it works properly. Sadly I can't give an answer if this is the best way to do this. But it seems to be a correct way. And without this it wouldn't work at all...

senortim’s picture

FWIW, I tried using the 7.x-1.x-dev version, but am still seeing these errors. Also, and I'm not sure if this is the same issue, my selection criteria reads "tid equals " and then nothing. The tid is getting saved, and the selector works (even with the non-dev version). I just can't see what it is without drilling all the way down to the setting (i.e., not in the variant summary.)

Anonymous’s picture

My post in #1630820: entity_field_value is completely broken tries to solve this. Please try it and comment ?

andypost’s picture

Marked as duplicate #1558708: Ctools bug in term rule ('tid equals') in Panels Selection rules
#4 is wrong because fields could have more than one storage column

andypost’s picture

Priority: Normal » Major
FileSize
1.84 KB

To actually check the field value ctools should iterate through storage fields and compare them one by one

spuky’s picture

The patch in #8 solved the Issue for me...

capellic’s picture

I applied this patch to Dev and it didn't solve my problem. But then my use case is different, I am not using a taxonomy reference field. I am using a List (text) field. My values are:

simple|Simple Page
index|Index Page
multi|Multi-Feature Page

I am trying to select a different Panel variant based on the value in the field. i add the field as a selection rule, select any one of the possible values, save the rule and then I see the error discussed above.

In the "Description" it says "value equals" indicating that the value wasn't recognized. If I go to edit the rule, I see the field with none of the values selected.

andypost’s picture

@capellic do you have this problem without patch?

Anonymous’s picture

I applied the patch in #8 and it didn't solve the issue. After the patch applied, I get still same error in same place

Notice: Undefined offset: 0 in ctools_entity_field_value_ctools_access_summary() (line 235 of /sites/all/modules/ctools/plugins/access/entity_field_value.inc).

  foreach ($value_keys as $key => $value) { // line 234
    $values[$value] = $elements[$key]['#markup']; // line 235
  }

Here some debug info:

print_r($value_keys);

/*
Array
(
    [0] => @tid_value
)
*/
print_r($values);

/*
Array
(
    [@tid_value] => 7
)
*/
print_r($elements);

/*
Array
(
)
*/
Anonymous’s picture

#8: 1520036-entity-field-8.patch queued for re-testing.

andypost’s picture

@emixiak this issue different, see for yours #1630820: entity_field_value is completely broken

merlinofchaos’s picture

Status: Needs review » Fixed

Committed and pushed andypost's patch.

Status: Fixed » Closed (fixed)

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

toddgee’s picture

Posted a similar defect here:
http://drupal.org/node/1812758

toddgee’s picture

Issue summary: View changes

more errors from same problem