Displaying Related Nodes

    Related nodes for specific books can be displayed in a block on book product pages by creating a view using a contextual filter and setting the view block to display on book pages.

    Note: For this to work, the book must be placed in a booklist of the related content type (in this example, ‘Event’). To learn how to create a booklist please review “Creating Booklists”.

    CREATE THE VIEW

    In this example, the related nodes we want to be displayed on book product pages are “Events”.

    Notes:

    • When working in settings always change the ‘For’ option from ‘All Displays’ to ‘This block (override)’ so that the changes you make only alter the block (or page) you are working on.
    • We highly recommend you save your 'view' after every step, as you create it. Especially when you see this message come up:  “* All changes are stored temporarily. Click Save to make your changes permanent. Click Cancel to discard the view.”

    Navigate to: Structure > Views > Add New View

    1. Fill in a ‘View Name’ - Example: Related Events
    2. Confirm ‘Show’ is set to ‘Content’ and type is set to ‘All’
    3. Deselect ‘Create a page’
    4. Select ‘Create a block’
    5. Set your display format - for this example, we’re using ‘Unformatted list’ of ‘titles (linked)’
    6. Enter the ‘Items per page’ you want to be displayed (this is the number of related nodes that will be displayed at one time) - If you're not allowing ‘all’ to display at one time we recommend selecting ‘Use a pager’
    7. Continue and Edit
    8. Under ‘Fields’ confirm ‘Content: Title’ is already in place - if not, add it.
    9. Under ‘Fields’ add any other additional field you would like displayed in this block - for this example, we’re also adding ‘Content:Event Date’
    10. Configure the fields you add - for ‘Content:Event Date’:
      1. Deselect ‘Create a label’
      2. Set your ‘Formatter’ to ‘Date and Time’
      3. Set ‘Choose how users view dates and times’ (we’re choosing ‘Short’)
      4. Set your display (we’re choosing Start date only)
      5. Apply (this display)
    11. Under ‘Filter’ select ‘Add’
    12. Select ‘Content: Type’
    13. Apply (this display)
    14. Configure the ‘Content: Type’ filter to be ‘Is one of’ and select ‘Event’
    15. Apply (this display)
    16. Expand the ‘Advanced’ section and select ‘Add’ next to ‘Contextual Filters’
    17. Select ‘Content: Books (field_products:model)’ (this is the default name of the standard booklist field - if you have added a custom field to this page select that filter option instead).
    18. Apply (this display)
    19. Configure contextual filter: Content: Books (field_products:model)
      1. Under ‘When the filter value is NOT available select ‘Provide default value’
      2. Set the ‘Type’ to ‘Raw value from URL’
      3. Set the ‘path component’ to 2 (book URLs are of the format http://storeURL/book/[ISBN] - The path component is 2 because the [ISBN] is in position 2 after the base URL)
      4. Apply (this display)
    20. Save

    You have now created the view but need to place the block.

    PLACE THE BLOCK

    Navigate to: Structure > Blocks

    1. Locate the block created under the ‘Disabled’ section and select ‘Configure’
    2. Enter a Block title (optional) - to display no title enter <none>
    3. Select the region of the theme you want to place it in
    4. Set ‘Show block on specific pages’ to ‘Only the listed pages and enter book/* into the text field
    5. Save block

    When visiting a book product page (yoursite.com/book/ISBN) for any book in a book list for an “Event” you should now see this block displayed showing all related “Events”.