5

I'm reeally struggling with this one. I just can't seem to wrap my head around the way Drupal and Views handles this pretty simple thing...

I have two content types:

  • Card
  • Card Content

Card has the following fields:

  • Title
  • Body
  • Display Order
  • Linked ID

Card Content has the following fields:

  • Title
  • Body
  • Linked ID

In Views, I would like to display:

  • Card Content - Title
  • Card Content - Body
  • Card - Display Order

If I were to write this as an SQL statement, it would be simple:

SELECT a.title, a.body, b.display_order
FROM card_content AS a
  INNER JOIN card AS b
    ON a.linked_id = b.linked_id


How do I achieve this?


Things to note: I originally had the Linked ID as a select box, taken from a set of predefined taxonomy terms. I have since migrated these to entity-references, that pull the data from the taxonomy terms (if that makes sense)?


EDIT: Okay, to clarify things a little...

Linked ID is a select box that's linked to a taxonomy vocabulary. This is purely to limit what a user can input.


As requested, here are screenshots of my Card and Card Content.

enter image description here enter image description here

9
  • Do you have any relation ( node reference or etc ) between this two content types?
    – Yuseferi
    Commented Sep 11, 2015 at 4:59
  • Do you mean like the linked ID, contained in both content types? That comes from the taxonomy?
    – Jack_Hu
    Commented Sep 11, 2015 at 5:09
  • No, a relation that connect this two content type to each other, I mean something like entity references(or node references) ?
    – Yuseferi
    Commented Sep 11, 2015 at 5:13
  • What exactly is "Linked ID" supposed to represent? It seems as though you're trying to associate Cards with Card Content, but you mention that Linked ID references a taxonomy term for some reason.
    – Aaron
    Commented Sep 11, 2015 at 5:18
  • @zhilevan no I don't. As I mentioned, I changed the Linked ID to an entity-reference, but I don't really know what I'm doing, nor what an entity-reference is...
    – Jack_Hu
    Commented Sep 11, 2015 at 5:50

4 Answers 4

0

You should create a entity reference field in Card name it as "card content ref"( reference it to "Card Content" content type ) , then in your views, add relation to "card content ref" then in your field list "Card Content - Title" and "Card Content - Body" field exists.

Also for tutorial and learning more about Realation between two content types read this article

2

Best way is to use entity reference

Below is the youtube link which will provide you step by step explanation of using entity reference module with views. https://www.youtube.com/watch?v=4Pdii7aFIvc

1

You can use this module..suitable for your requirement https://www.drupal.org/project/entityreference

0

We have 2 content types of A and B:

  1. We add content type B to the Filter Criteria of the view.
  2. Add an nid of content type A using Contextual Filter in the advance Options.
  3. Add a relationship of content type B in reverse order in the relationship field in advance options.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.