This is a site for a gallery where woocommerce products are children of their artist parents. Im creating a product content template that has in different spots throughout it information from its parent artist. I know how to make a view to pull in data from the parent. Im wondering though is there a more efficient way of doing this except for making separate views for each bit of non-contiguous data i need from the parent record.
Is there a best practice- or better one than make so many inside views
Thanks
Hello and thank you for contacting the Toolset support.
I assume that the relationship between artists and products is a One-to-many relationship, right? If that's the case, you can get the data from the parent artist without using a view. If you are using blocks for the content template, use a single field block and choose the dynamic source to be from the parent post.
If you are building the content template using shortcodes, you can pass the parent post in the item attribute https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/
If the relationship is many-to-many one, you MUST use a view.
I hope this makes sense. Let me know if you have any questions.
Thats great Jamal thanks for pointing that out. Is there a way then to build conditional output around that, so for example only display some content if this is not null
[types field='artist-dates' item="@artist-product.parent"]
Of course. You can use the same shortcodes inside a conditional shortcode. Just note that the types shortcode needs an enclosing shortcode"/types":
[types field='artist-dates' item="@artist-product.parent"][/types]
Thanks Jamal- I appreciate the help