0

I have two content types: Parent and Child

I have an entity reference field (called "Link") in parent content type referencing it to child content type.

I am using inline entity forms module for the entity reference field .

I want to know if there is a way to achieve the following:

Question 1:

I want to have a read more button on parent content type, which would open the first entity referenced child page.

Question 2:

I want to have a pager in the child page which would link to the other child pages of the same entity referenced parent content type. (something similar to what books module provides for book child in child pages)

Any help would be highly appreciated. Thank You.

0

There might be better way of doing that.

But one of the way will be to use views module

Answer to question 1:

  1. Go to your_site/admin/structure/types/manage/content_type/display
  2. Change the reference field format to Rendered entity
  3. Click the setting and make sure Show links is checked

Answer to question 2:

  1. Install the module views if you don't have it already
  2. Go to yoru_site/admin/structure/views/add
  3. Give your view name for example read more button to parent content type
  4. Unchecked Create a page and Check Create a block
  5. Click Continue & edit
  6. Change format to "Table"
  7. Click add filed and select the fields you want to show
  8. Click add Filter criteria and select the criteria you want
  9. Click the Advance and Add Contextual Filters
  10. SelectContent Content: Nid"
  11. Select Relationship as content entity referenced from your_xyz
  12. Change the option for When the filter value is NOT available to Provide default value and select Content ID from URL.
  13. Change When the filter value IS available or a default is provide to Specify validation criteria and select Content from Validator select field, and select the parent content.
  14. Make sure Filter value format is = to Node ID
  15. Make sure Action to take if filter value does not validate is = Hide view
  16. Click Apply
  17. Add a Relationship, Click add and select Entity Reference
  18. Click Save.
  19. Go to yoru_site/admin/structure/block, search for the new view name black you just added.
  20. Click configure change the Visibility settings to content type and select the parent content type.
  21. Set the Region where you want the black to be display.
  • Thanks for the speedy response. I think i had not explained the question well. I made some edits, hope it helps you understand it better. I used your answer to the second question to solve the first problem. Yes I had views installed ( Can't imagine a day with drupal without views, All hail Merlin :) ) – H.Saraf Jan 7 '16 at 20:42
0

I solved my first question with the help of the detailed instructions from Yama as below:

  1. Create a block view of html list .
  2. Use relationship: Entity Referencing.
  3. Click Advance and Add Contextual Filter
  4. SelectContent Content: Nid"
  5. Select Relationship as content entity referenced from your_xyz
  6. Change the option for When the filter value is NOT available to Provide default value and select Content ID from URL.
  7. Change When the filter value IS available or a default is provide to Specify validation criteria and select Content from Validator select field, and select the parent content.
  8. Make sure Filter value format is = to Node ID
  9. Make sure Action to take if filter value does not validate is = Hide view
  10. Click Apply
  11. Click Save.
  12. Go to your_site/admin/structure/block, search for the new view name block you just added.
  13. Click configure change the Visibility settings to content type and select the parent content type.
  14. Set the Region where you want the black to be display.

Instead of Steps 12 to 14, I used Display Suite, Block Field feature.

It works like a charm.

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.