You have a one-to-many relationship between Books and Extras, and from the Book template you want to display some information from related Extras posts.
As there may be many related extras, there isn't a unique source for the field, how should the block know which child extras post to use as the source?
In this case you need to create a View to list the child posts, and then in the output section of that View you will display the desired fields belonging to the child posts.
The other way round you don't need to use a View, because from the context of an "Extra" there can be only one parent, which can be specified as a source directly.
When creating the View you will need to add a Query Filter for the relationship (i.e. show Extras related to the current Book). This workflow will be simplified in the next release, which you can see in the current beta version of Blocks.
Sorry Nigel. I knew that. Must have taken the stupid pill this morning.
One related question. A book may or may not have extras. We want to display a heading block “Extras” and the view block only when there is at least one Extra linked to the Book. How do we test for that in the conditional block they would be wrapped in?
This is one of those things that is a little tricky in Blocks compared to classic Views.
To avoid duplicating querying the database for your View results, you could previously add the heading to the output of the View, inside the results found section but before the loop itself (so it would only be output once, and only if there were results).
That's not possible with Views made using the block editor, so you need to use the output of the View itself in the conditional test (checking whether it equals the "No items found" text, or something else), and for complex Views or where you are not using pagination that can add quite a bit more overhead to your queries.
In this case I would be inclined to define a custom shortcode or function that uses the relationships API and returns the number of child posts for the current post, and use that in the condition.
Here's an example of a general-purpose shortcode to do just that which you can use: hidden link
You will need to register the custom shortcode at Toolset > Settings > Front-end content before it can be used for your condition.
So add a conditional block, using that shortcode for the condition, and include both the heading block and the View itself inside this conditional block.
I just created an internal request ticket to be able to do the same in Blocks as was previously possible with classic Views (add content to the items-found section outside of the loop). I recall during the design phase we were trying to simplify the UI when creating a View, but may have gone a little too far.
Thanks. Use case is pretty common for us. Need to do the same thing with a many to many between books and blog posts (same for authost and series)
That way content managers can do post, link one or more books, authors and/or series to it. The iview of linked object shows below the post. On the book page, same will let us show posts linke dto that book
I expect it will be a while before there are any changes to the plugin, although hopefully we'll find a way to facilitate it within the UI without complicating things.