Thanks for a great module, I've configured it to display a vocabulary along with a node in which it is referenced using Entity Reference, Page Manager, Panels, Views Content and Views and it seems to be working great. When I was setting it up though, I came across a couple of quirks that seem to originate in the Page Manager/Panels vocabulary relationship - I'm not totally sure if it's a bug or if I'm doing something weird as I'm just starting to get my head around the config and I haven't delved into the code.

I couldn't find any reference to this issue in the queue so I'll do my best to explain it here. Apologies if I'm way off the mark or if this issue has already been addressed:

  • I have a node type with an Entity Reference field to a vocabulary.
  • I'm using the Page Manager node override, with a selection rule for my content type.
  • In my Page Manager/Panels variant's contexts I added a relationship on the vocabulary reference field, here lies the first quirk of this setup: the relationship is listed as Node from Node (on Vocabulary [field_vocabulary]). Since the reference is to a vocabulary I would expect the relationship label to say Vocabulary from Node...
  • Moving on to the second related quirk: My Views content pane has a contextual filter Vocabulary ID and so I want my Pane Settings > Argument Input to be From Context > Taxonomy > Vocabulary ID however if I set it to this my View Pane will not be listed in the Panels content options. I think this is because Panels does not recognise the relationship to my vocabulary as containing a vid.

It seems I can actually work around this (though I haven't tested it thoroughly) if I set the Views pane settings argument input to From context > Node > Vocabulary (field_vocabulary), then go back to my Panel's content listing where it now show's my view pane allowing me to add it, and to select the Node from Node: On Vocabulary [field_vocabulary] context in the config. Then after saving the Panel, I can go back to the Views pane settings and reset the argument input to From Context > Taxonomy > Vocabulary ID which allows my View to render the correct results.

If my interpretation is correct and this is a bug, then I think basically what is happening is that Panels relationships does not correctly recognise an Entity Reference to a vocabulary, which consequently does not recognise the presence of a vid argument in the context... maybe?

Thanks for your time.

Comments

Letharion’s picture

Just checking, do you really mean that you refer to a _vocabulary_, or do you really refer to a _taxonomy term_?

lwalley’s picture

Thanks for the quick response. I really mean a vocabulary, not a taxonomy term.

Letharion’s picture

I've never heard/seen of referncing a vocabulary, so it wouldn't surprise me in the least if it's mostly untested. On the other hand, I'm fairly certain the relationship-from-entity reference code is as entity agnostic as ERs themselves, so it _should_ work.

lwalley’s picture

I've had a quick look at the ctools relationships plugin code and yes you're right about it being agnostic. It looks like it relies on the available fields' own foreign key information (@see ctools_entity_from_field_get_children() and ctools_field_foreign_keys()). In this case I'm using an entity reference field to a vocabulary but when I dump field_info_fields() I see that the foreign key information for that field returns:

  [foreign keys] => Array (
    [node] => Array (
      [table] => node
      [columns] => Array (
        [target_id] => nid
      )
    )
  )

I think this explains why the relationship is listed as "Node from Node" even though it is a taxonomy_vocabulary.

My quick assumption at this stage is that the foreign key information for the field should be taxonomy_vocabulary, but I'd need to do a bit more digging to figure that out for sure. If that is the case then perhaps this is an issue for the entityreference project?

lwalley’s picture

Status: Active » Closed (won't fix)

Ah yeah, it seems this foreign keys problem has already been identified in the entityreference issues queue #1340748: Add CTools relationship #33 and looks like its a core issue as well #34, see #1416506: Field schema foreign keys support is broken

I'll try out the patch in #33 #1340748: Add CTools relationship. Closing this issue as won't fix for the panels project, thanks for your time it is much appreciated.

Update (temporary solution):

Patch (http://drupal.org/files/entity_reference-add-cTools-relationship-1340748...) from #33 #1340748: Add CTools relationship solves the issue I described in this ticket. The patch updates the foreign keys information when you manually save the entity reference field. Once the foreign keys are correct ctools relationships and panels work as expected - in my case adding a new relationship 'Taxonomy Vocabulary from Node', and now my Views Content Pane settings correctly offers the 'Taxonomy Vocabulary from Node' relationship context for selection as the Views argument. Note: The entityreference patch is a temporary solution, preferred solution is a fix for #1416506: Field schema foreign keys support is broken.

cornelyus’s picture

Hey..

I have this issue too.. I have a content type with a entity reference for a taxonomy term, and on Panels, this relationship isn't available..

The patch you applied , what version of entities module were you using?

thanks

EDIT: I had a release candidate version, and updated to the newer one and now it works..
thanks