-1

I'm trying to learn about basic drupal concepts while planning out my site. I'm trying to figure out the drupal way to accomplish things. Actually I'd also like language to describe what functionality I'm looking for and whether it can be done through the Drupal 8 GUI or requires some module.

I've created two content types BOOK and AUTHOR. Both have about 5 fields.

I want to have a third content type called BOOK REVIEW.

When you input data in the form for BOOK REVIEW, I am using an entity reference field which autocompletes in the form display. In the form display for BOOKREVIEW, I want to type in the name of the AUTHOR (Charles Dickens) and then drupal will offer me the choice I want from an AUTHOR node. AUTHORNAME is one field in the AUTHOR content type.

Here's what I don't understand.

When I am creating/editing a BOOKREVIEW, I want a way to display not only the AUTHORNAME field, but also pull data for 2 or 3 other fields in the same Charles Dickens node for AUTHOR (such as NATIONALITY or YEAR OF DEATH). So in the form display for BOOKREVIEW, I would have no reason to input YEAR OF DEATH or NATIONALITY. Yet I don't know how to put data from thee fields in the BOOKREVIEW display. I would just expect it to be called and available for the display as a result of having already input CHARLES DICKENS in the form display for BOOKREVIEW.

Initially I thought I need to establish a RELATIONSHIP between one BOOKREVIEW node and one AUTHOR mode. But relationships seems to have to do with VIEWS only, and I'm not really interested in making a view. (A view is a way of display more than more than one nodes of a content type, and I am only interested in producing a display for one node. Or am I wrong?

What would be the best way to accomplish this task of invoking additional fields from a single AUTHOR mode by simply creating a content reference for AUTHORNAME?

EDIT: My primary purpose is to produce a site with articles/blogposts, etc. I'd like multiple ways to sort nodes, plus having books and authors separate simplify the process for users of creating reviews. It's not a primary goal, but keeping these things separate make it easier to create alternate ways to browse reviews. –

  • You are very right that duplicating data is not the right thing to do. If the data is already on the author, there is no specific need to place it on the review. What is not yet entirely clear to me is what you are trying to achieve. If people view the review you want to display book + author data as well? In that case You might want to consider EVA for fetching and rendering the associated data. Finally, views is not specifically for rendering lists and can be used perfectly for single pages as well, but it is a little harder to align and style all data. – Neograph734 Sep 16 '17 at 23:10
  • Thanks for that insight that views can be used for single pages. Didn't realize that. Yes, it is true that I am also thinking about including fields from possibly both AUTHOR and BOOK content type. I am just not sure the right way to get this done in drupal. – idiotprogrammer Sep 17 '17 at 0:09
  • My primary purpose is to produce a site with articles/blogposts, etc. I'd like multiple ways to sort nodes, plus having books and authors separate simplify the process for users of creating reviews. It's not a primary goal, but keeping these things separate make it easier to create alternate ways to browse reviews. – idiotprogrammer Sep 17 '17 at 2:29
  • This is my first site (on drupal anyway), so I don't know how much complexity in content models is manageable and how much is too much... – idiotprogrammer Sep 17 '17 at 2:30
  • Could you edit such details into the question next time? Would make the overall question better. And have a look at EVA I linked to in my previous comment. The tutorial on their page is pretty good. – Neograph734 Sep 17 '17 at 9:24
0

Once you have connected your Book node with the Author node via an entity reference field, you can display any subset of the Author node within the Book node without additional modules:

  1. Create a custom display mode. (Structure >> Display modes >> View mode)
  2. Enable that display mode for Author and configure the fields that you wish to display. (Structure >> Content Types >> Author >> Manage Display)
  3. Configure the entity reference field in Book to display as Rendered Entity and set it to use the view mode created above. (Structure >> Content Types >> Book >> Manage Display) Format: Rendered Entity; Format Setting: mode created in step 1.
  • I assume you mean "referenced entity," (not rendered entity) right? I assume that the custom display mode is "display" and not a "form display," right? On step 3, instead of "view mode" you meant to say "custom display mode," right? (I agree that these terms are easy to confuse!) Perhaps I'm missing something or a step is missing, but how does choosing the custom display mode for BOOK result in other fields from AUTHOR content type to be accessible? – idiotprogrammer Sep 18 '17 at 5:59
  • I edited the steps above to be more clear. I do mean Rendered Entity - it is a format option for entity reference fields. You will have the selected fields of the chosen Author reference rendering within the Book node. – FatherShawn Oct 15 '17 at 18:09
  • Thanks for the revision and clarification. I'll try it out! – idiotprogrammer Oct 15 '17 at 22:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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