having the following configuration:

views content pane:
a contextual filter: has taxonomy term id
override title: Related News for %1
Allow multiple values
validation with filter type: Term IDs separated by , or +

the views pane preview works for single and concatenated term id's as contextual filter argument.

what doesn't work is embedding the views pane sucessfully into a panel:

panel for node template
context: relationship "Multiple terms from node" for a specific vocabulary with option OR + as concatenator
content: passing the context to a views content pane as "Term ID of all term, separated by + or ,"

the argument seems not to get passed. it will when using "Term ID of first term" instead of "Term ID of all term, separated by + or ,"

this is related to the support request #1111384: How to create a panel with related content based on multiple terms.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bryancasler’s picture

subscribe

merlinofchaos’s picture

There was a problem here a while back that had to do with the fact that there are actually two entity term contexts -- original one and the entity based one -- and the multiple terms one is kind of off in lala land. I could swear I fixed that but maybe I missed something. :/

jmones’s picture

subscribe

Joe Vallender’s picture

subscribe.

I've just been doing a bit of messing around with this trying different combinations of +d together term Ids directly into the views preview function and getting the behaviour there too, when panels hasn't come into play at all. Not sure if that helps narrow it down a bit (...or if that is old news, fixed and my views module is a little out of date)

Edit: having re-read an actually retained the original post. it seems my info is at odds with the initial info. disregard as appropriate :)

Hanpersand’s picture

Subscribing, just in case that new follow button is just for show.

suldan’s picture

Couldn't this be a ctools related problem? Maybe the relationship-plugin in ctools/plugins/relationships/terms_from_node.inc ? When I'm not misstaken the (+ OR)-concatenator did work for me but not (, AND).

By the way: I still dont have any problems creating related content based on multiple tid's by using content:has taxonomy term ID. Without any arguments from panels, without any specification of validation and without any additional relationships. Just allow multiple values.

Using last devs of all

Letharion’s picture

Assigned: Unassigned » merlinofchaos
FileSize
4.81 KB
2.44 KB

I can't reproduce the original problem, as I get a SQL error when I try.

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1', '2'' at line 1: SELECT tid, name FROM {taxonomy_term_data} WHERE tid IN :tids_0, :tids_1; Array ( [:tids_0] => 1 [:tids_1] => 2 ) in ctools_context_terms_convert() (line 84 of [path]/sites/all/modules/ctools/plugins/contexts/terms.inc).

Looks like missing () after IN?

Letharion’s picture

For future reference, please, please upload exports of views/pages. It makes it a great deal easier to debug for me.

wmostrey’s picture

I have the same issue without Panels, I'm only using Views 7.x-3.0-rc3.

To reproduce:

  • Add a contextual filter "Content: Has taxonomy term ID"
  • Check "Allow multiple values"

When I add 1 tid as an argument, the results are as to be expected.
When I add "tid1,tid2" or "tid1+tid2" as an argument, no results are returned.

I also tried this with the option "Filter value type" > "Term name converted to Term ID" but this didn't change the results.

wmostrey’s picture

Priority: Normal » Major

This would seem to require a new "Filter value type" that combines "Term name converted to Term ID" and "Term IDs seperated by , or +".

Update: This ticket seems to do just that: #1248300: Contextual filters: Taxonomy filter validation using multiple term names. I'm not sure if this feature/bug falls in the scope of this issue though.

StuartDH’s picture

The views patch in the above post doesn't seem to work properly.

StuartDH’s picture

I've attached a Feature with a content type, view and panel that works if there's only one term reference field on the node.

But when there's two or more term reference fields, and the fields have content in them on the node...

StuartDH’s picture

I think I've managed to identify the problem.

Everything works OK until you have more than one Term reference field in the content type, with terms in it

With only one term reference field on the content type, if the panel content view Taxonomy term: Term ID is set to "Term ID of all term, separated by + or ," everything seems to work OK. The panel sends multiple term IDs to the view and the panel's view pane shows the multiple terms.

If you add a second term reference field to the content type, the panel still displays the above view properly...

until you add/select terms in the second term reference field on the node...then the panel stops sending "Multiple terms from node" to the view for the first term reference field.

The above issue exists regardless of whether the panel's Context > Relationships > Multiple terms from node > Vocabulary boxes are checked for both, either, or none of the above vocabularies.

StuartDH’s picture

To recreate the issue with ctools, views and panels modules installed

1. Create a simple 'Colours' vocabulary and add terms 'Red, Green and Blue' - (admin/structure/taxonomy/add)

2. Add a 'Colours' taxonomy field to the Articles content type...widget 'select list' or 'auto complete' and number of fields 'Unlimited' - (admin/structure/types/manage/article/fields)

3. Create a 'Colours View' with machine name 'colours_view' - admin/structure/views/add

  • Show 'Taxonomy Terms' of type 'Colours' sorted by 'unsorted
  • Name 'Colours', path 'colours'
  • Unformatted list of 'fields'

In admin/structure/views/view/colours_view add 'Taxonomy term: Term ID' context filter

Set 'WHEN THE FILTER VALUE IS IN THE URL OR A DEFAULT IS PROVIDED' to:

  • Specify validation criteria - Validator > Taxonomy Term > Colours
  • Filter value type - Term IDs separated by , or +
  • More - check the box for 'Allow multiple values'

4. Create a node template panel for Articles - admin/structure/pages/nojs/operation/node_view/actions/add with:

  • Selection Rules - Node Type: Article > All criteria must pass.
  • Contexts > Relationships - Multiple Terms from Node > select 'Colours' vocabulary
  • Choose Layout - Any
  • Panel Settings - Default
  • Panel Content tab, add content > Views > Colours View > Taxonomy term: Term ID > Multiple Terms from Node > Term IDs separated by + or ,
  • Create Variant

5. Create an article and select two or more options from the colours field - save the page and it should show the colours listed in the view

6. Edit the node, add anything to the 'Tags' field and save the page - the above 'Colours View' will disappear

  • The same applies when using any other additional terms reference
  • From post #6 - using Concatenator + (OR) or , (AND) doesn't seem to make any difference...neither works
StuartDH’s picture

I don't know if it helps, but configuring the view pane's settings to Taxonomy term: Term ID > Term ID of first term doesn't result in the above issue.

Unlike Taxonomy Term IDs separated by + or , the Term ID of first term option produces the required view even when there are multiple term reference fields on the node

StuartDH’s picture

It looks like a fix for this issue could also fix several similar Panels issues - http://drupal.org/node/1111762 and possibly this one - http://drupal.org/node/1424020

as well as many Panels-related issues in the Views module like http://drupal.org/node/1369772

matglas86’s picture

@StuartDH you are right. The other issues are duplicates of this and a fix here should fix the others too. I'm having the same issue here. I have not taken the time to digg deeper in the filter and see what happens. But I have the same setup as people before described and get no result with more then one term but I have good results with only one term.

node9’s picture

+1

StuartDH’s picture

Status: Active » Needs review

Looks as though this is now fixed.

All looks OK when creating something similar to #14 with Drupal 7.12, Ctools 7.x-1.0, Panels 7.x-3.2 and Views 7.x.3.3

merlinofchaos’s picture

Status: Needs review » Fixed

'needs review' means there's a patch.

PieterDC’s picture

Thanks StuartDH for your hints. I managed to configure my panel/view.

Status: Fixed » Closed (fixed)

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

hixster’s picture

Status: Closed (fixed) » Active

Sorry, reopening. I am experiencing exactly the same issue as described in http://drupal.org/node/1285012#comment-5724598 using
Drupal 7.17, Ctools 7.x-1.2, Panels 7.x-3.3 and Views 7.x.3.5.

When selecting a single term on my node the view is displayed by panels. As soon as I select multiple terms the view disappears.
I have tried using both a View with master display in my panels as well as a Content pane (I setup the arguments to accept multiple tid's).

Zero4ffect’s picture

Issue summary: View changes

I am also experiencing this issue:
Drupal 7.26
Ctools 7.x-1.4
Panels 7.x-3.4
Views 7.x-3.7

Selecting a single term allows the term id to pass to the panel but using multiple terms causes the contextual filter to invalidate.

yogeshchaugule8’s picture

Status: Active » Closed (fixed)
FileSize
225.55 KB

For any one who will be visiting this issue, here is a screenshot of the working configuration of contextual filter in view for multiple terms. I've got this working.

Marking the thread as closed.

Yogesh

daggar’s picture

#25 worked for me. Thank you yogeshchaugule8

JD

dasjo’s picture

Title: Contextual filter: Has taxonomy term ID doesn't work with multiple terms » Panels context issue with contextual filter: Has taxonomy term ID doesn't work with multiple terms
Assigned: merlinofchaos » Unassigned
Status: Closed (fixed) » Active

#25 works fine within views, though i haven't found a way to configure passing on the multiple terms context via panels properly.

Renaming as this reflect more what was in my initial issue summary

_nolocation’s picture

I tried the above and 100 other things but I couldn't get this to work correctly.
I finally used php to return the arguments I needed and even though this might not be the optimal solution, it works. The disadvantage is that it's not flexible and has to be adapted to the context where the view is displayed.

The following goes into "Provide default value" -> "PHP Code".

$ret = '';
if(arg(0) == 'node'){
    $node = node_load(arg(1));
    $terms = field_get_items('node', $node, 'field_technologies');
    $lgt = count($terms)  - 1;
    foreach($terms as $key => $term) {
      if($key == $lgt){
        $ret .= $term['target_id'];
      }else{
        $ret .= $term['target_id'].'+';
      }
    }
  }
return $ret;
calebtr’s picture

I also can't get #25 to work - I'm using the same configuration, but for a Content pane instead of a block.
I've got 'Argument input' setting set to 'Input on pane config'.

The view works perfectly in preview mode - I can pass 1+2 and get the expected results. When I configure the pane to use "1+2", I only get results for term 1.

When I dpm() the display in hook_panels_pre_render(), the setting has already been stripped down from "1+2" to "1" - possibly, it is being validated as a single taxonomy term, but I'm not sure where.

My use case requires always ORing in a specific term, so I did solve this by editing the argument in hook_panels_pane_prerender():

function the_module_panels_pane_prerender($pane) {
  if ($pane->subtype == 'the_view-the_display') {
    $pane->configuration['arguments']['tid'] .= '+2'; // it's a string
  }
}

In another use case, this technique might not work.

katrien_w’s picture

Try putting argument input to 'no argument', according to instruction of Suldan in https://www.drupal.org/node/1111384#comment-4742022. It works for me on a content pane.

mudasirweb’s picture

Hi
#25 worked for me, Thanks yogeshchaugule8