Home › Toolset Professional Support › [Resolved] View with Custom Fields from multiple CPT's
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 |
---|---|---|---|---|---|---|
- | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | - |
- | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | - |
Supporter timezone: Europe/London (GMT+00:00)
This topic contains 6 replies, has 2 voices.
Last updated by Nigel 1 year, 2 months ago.
Assisted by: Nigel.
Tell us what you are trying to do?
An association organises worldwide "Exhibitions for Collectibles"
CPT EasyExhibitions
Exhibitors come to those Exhibitons
CPT EasyExhibitors
and show their Collections
CPT Easy Collections
At the end of the Exhibition the Organizser attributes 3 different Rewards to the best collections
CPT EasyPrizes
(National Prize, International Prize, Prix d'Honneur)
The main thing that I need is a List showing the various Exhibitions, with the anually Rewards, the winners and their collections.
I'm somehow lost between Relationships and Post References
So far I have following 2 Relationships
EasyExhibitors Easy Collections (one to many)
EasyExhibitors [0 .. 1] << Easy Collections [*]
easyexhibitor-easy-collection
EasyExhibitions EasyPrizes (one to many)
EasyExhibitions [0 .. 1] << EasyPrizes [*]
easyexhibition-easyprize
but I have problems to bring the fields into a view to get a result as attached screenshot
Is there any documentation that you are following?
Is there a similar example that we can see?
The site is a test site - you can have access if you like
What is the link to your site?
hidden link
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Hi there
This sounds like a fairly complex set up.
Your example, shown in the screenshot of a spreadsheet, looks relatively simple, where each Exhibitor exhibits only once, showing only a single Collection. But I suspect the possibilities are more complex than you show, if we could please clarify what you are aiming for.
The key relationships are between Exhibitions, Exhibitors, and Collections.
Collections can only ever belong to a single Exhibitor, correct? But Exhibitors can have multiple Collections, yes?
But an Exhibitor can presumably exhibit at multiple Exhibitions, and at each Exhibition they may exhibit different Collections rather than always exhibiting the same Collections. Would that be correct?
If you can confirm we can see if we can suggest some arrangement of post types and relationships that meets your needs.
Hi Nigel,
After trying 1 - 2 days without results, I'm reassured that you classify it as "fairly complex".
You are 100% correct with all your assumptions, but you have to add the KEY ELEMENT "Prize or Reward" CPT (National Prize, International Prize, Prix d'Honneur), as it is the Prize that brings everything together, and connects them all.
The List/View should only display the WINNERS of the 3 Prize Categories, together with their "winning collection".
It is at the end of the exhibition/competition that a winner is declared in the 3 different Prize Categories.
The Idea is, that the webmaster then "attaches" via TS Form the 3 Prizes to the Collection of the Exhibitor.
So in fact, the Prize triggers the display of the list. Only the winners appear on the list.
Thanks for your support
best regards,
Georges
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
I'm still thinking about this, in the context of certain constraints with Toolset relationships that limit the scope of what is possible.
I'll update you tomorrow.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Reviewing this, it seems the key connection is between collections and exhibitions, which is what a prize can be awarded for (e.g. the National reward at the Toronto 2020 Exhibition is given to the Cymbals 1990-1999 Collection, which belongs to the Exhibitor Charlie).
That collection-entered-in-an-exhibition connection is central. The exhibitor is an extra bit of data (related to the collection), and the prize is an extra bit of data (specific to the competition entry).
So, in the context of what is possible with Toolset relationships we would create a many-to-many relationship between Exhibitions and Collections. Each connection represents an entry (of a collection) to the competition for that exhibition.
Include an intermediate post when making this relationship. I suggest calling the intermediate post type entry rather than the default exhibition-collection auto-generated from the post type slugs.
Add a relationship field for Prizes, a select field with the options "National Award", "International Award", and "Prix d'Honneur".
When connecting Collections to Exhibitions set that field to one of the prizes, if appropriate.
You will also then need a one-to-many relationship between Exhibitors and Collections.
That should enable you to add all of the data and have everything mapped out and connected correctly.
You will then have the question of displaying data.
The kind of structure you are discussing, with Exhibitions, then Prizes, then corresponding Exhibitors and the Collections will require nested Views, meaning you would need to be using the legacy Views editor for this.
The first, outer, View would query Exhibitions. (That will give us Toronto 2020, New York 2021 etc.)
Then we need a View nested in the output of this first View that queries the intermediate post type Entries. It will need a relationship Query Filter to return only entries that belong to the current Exhibition, and a second Query Filter to only return entries that have a value for the Prize custom field (only show prize winners).
In the output section of this nested View we can output fields from the Entry intermediate post itself (i.e. the name of the prize), or from the connected Collection (the name of the Collection). We can't output the name of the Exhibitor the Collection belongs to. We need to add another nested View for that, to query Collection posts with a relationship Query Filter to return only the Collection post connected to the current Entry intermediate post. In the output of this third View you will then be able to output fields of the parent Exhibitor post.
One tip for when you set up the Prizes relationship field is to add options with text labels (e.g. "National Award") but numeric values, where the numbers are the order you want the prizes to be output. In the second View to query Entry posts, order the results by this Prizes field.
That's quite a lot to digest, but hopefully you can follow the logic.
Thank you very much for your brain-work and your detailed step by step instructions.
In short:
I think I got the bits and pieces together, however I don't get the 2 "Relationship Query Filter" right.
Maybe you can have a quick look on my setup, and give me a hand on the Query Filter.
Here the outcome so far:
WP Backend "Exhibition Singapore" with collections attached an with 3 Prize Awards
hidden link
Front End without any Filter
hidden link
My Problem is at View Nr2 which I named "View intermediate Entries v01"
It will need a relationship Query Filter to return only entries that belong to the current Exhibition,
> and a second Query Filter to only return entries that have a value for the Prize custom field (only show prize winners).
relationship Query Filter 1
hidden link
> I don't fully understand how to get the Filter working.
Here some details about the expected result:
Setup:
Singapore:
attached a lot of collections + 3 Prize Award Attribution
National Award: Basses Rickenbacker 1965-1975 (by Paul)
International Award: Cymbals Paiste 1960-1976 (by Charlie)
Prix d'Honneur: Lyrics 1965-1970 (by John)
Toronto:
attached 3 Guitar and 1 Cymbal Collection BUT NO Prize Award Attribution
New York:
NOTHING ATTACHED
> Outcome should be that only Singapore shows 3 Lines of prizes.
Toronto empty as no Prizes attributed
New York empty as no collections attached at all
My Toolset Details:
CPT collections
name-collection
icon-collection (image)
CPT exhibitions
name-exhibition
country-exhibition
date-from-exhibiton
date-to-exhibition
CPT exhibitors
name-exhibitor
RELATIONSHIPS:
a)
exhibitor-collection
exhibitors [0 .. 1] << collections [*]
b)
entry
exhibitions [*] << entries >> collections [*]
Fields attached to this relationship:
prize-attribution (Select field)
VIEWS
[A]
View exhibitions v01
> first outer view - to query Exhibitions
<h2>[wpv-post-link]</h2>
[wpv-view name="view-intermediate-entries-v01" orderby="prize-attribution" order="asc"]
[B]
View intermediate Entries v01
> nested view to query the intermediate post type Entries (from many-to-many relationship Exhibitions & Collections)
[wpv-post-link]<br>
<div class="xred">[types field='prize-attribution'][/types]</div>
<div class="xblue">[types field='name-collection' item='@entry.child'][/types]</div>
[wpv-view name="view-owner-of-collection-aka-exhibitor-v01" orderby="prize-attribution" order="asc"]
[C]
View Owner of Collection aka Exhibitor v01
> nested view to query collection POSTS with a relationship Query Filter to return only the collection post connected to the current ENTRY to output "Parent Exhibitor Fields"
[wpv-post-link]
[types field='name-exhibitor' item='@exhibitor-collection.parent'][/types]
Many thanks again for your support
Best regards
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
The post relationship query filter, in this screenshot hidden link, is wrong.
Instead of Any relationship, specify which relationship this refers to (it's the Exhibition << >> Collection relationship), and then select as related items of the current post in the loop.
The "current post in the loop" comes from the outer or parent View that queries exhibitions. So in the first iteration of that outer View the current post will be "Singapore 2023", and so only the entries corresponding to that exhibition will be returned by the inner View.
Hi Nigel,
many thanks for your valuable guidance - my challenge is now 100% resolved.
With appreciation
Georges