Skip Navigation

[Resolved] best practice creating views of parent data

This support ticket is created 3 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 4 replies, has 2 voices.

Last updated by Steve 3 years, 8 months ago.

Assisted by: Jamal.

Author
Posts
#1993811

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

#1994265

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.

#1994459

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"]

#1994489

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]
#1994493

Thanks Jamal- I appreciate the help