Hi,
I got the following error on a panel displaying the terms of a node:

Notice: Array to string conversion in ctools_node_terms_content_type_render() (line 94 of httpdocs/sites/all/modules/ctools/plugins/content_types/node_context/node_terms.inc).

And it displays for 3 terms only

ARRAY, ARRAY, ARRAY.

I use ctools rc1 and panels 7.x-3.0-alpha3.

Thanks for going into this!
Greetings,
Martijn

Comments

summit’s picture

Hi,
It only happens when I choose as a pane setting for the node being viewed terms pane:
- All vocabularies

If I choose, say the geographical vocaubulary the notice is not shown, and the terms are correctly output.

Greetings, Martijn

JamesAn’s picture

I can confirm this. The $terms array in ctools_node_terms_content_type_render() can be an array of strings or an array of term arrays (each array having a 3 element: title, href, and attributes).

Tracing the if statement, which constructs the $terms array, beginning on line 50, the $terms array is not an array of strings either if "all vocabularies" is selected or if the term formatting is selected as taxonomy links. The $terms array is correctly an array of link, which have those 3 elements when the formatting is taxonomy links as the theme('links') call uses these. In the other cases, the $terms array should be an array of strings.

JamesAn’s picture

Status: Active » Needs review
StatusFileSize
new2.13 KB

I've created a patch that should fix this. Please review this.

The patch removes the separate logic used to generate the $terms array based on whether a vocabulary is selected or all vocabularies are included, since the $terms array structure should be the same regardless. Instead, if a vocabulary is selected, all terms not part of that vocabulary is simply excluded.

JamesAn’s picture

We could also use EntityFieldQuery instead of taxonomy_term_load_multiple() and just add a propertyCondition('vid', $conf['vid']) before calling EntityFieldQuery::execute() if $conf['vid'] exists (i.e. a vocabulary is selected). This should be more efficient since irrelevant terms are not loaded (whereas currently all terms associated to the node are loaded and then filtered out).

merlinofchaos’s picture

StatusFileSize
new885 bytes

I like this patch better: Can I get verification this works?

merlinofchaos’s picture

Status: Needs review » Fixed

Committed.

Status: Fixed » Closed (fixed)

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