Skip Navigation

[Resolved] Need suggestion on how to format post types / relationships for site

This support ticket is created 2 years, 9 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.

Our next available supporter will start replying to tickets in about 2.18 hours from now. Thank you for your understanding.

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 digiumM 2 years, 9 months ago.

Assisted by: Jamal.

Author
Posts
#2116717

I need a suggestion on how to layout the post types and relationships for a site. I have tried a few things, but I am not getting the results I wanted. It may be due to using elementor as the page builder, which is preferred.

What I want to show:
--------------------------------------------------------
Basic Wooden Axe (Title of Recipe)

(view listing possible combination of items needed in the recipe and the quantity of the items needed)
possible combinations:
knotwood x 3
magnolia tree wood x 3
non-basic wood x 3

produces item: advanced wooden axe (i haven't added this relationship yet, but was planning to add a relationship - "Produced from recipe" and then on that item page, it would link back to the post of the recipe)

------------------------------------------------------

Currently, I have
Post type: Recipes
Post type: Items

Post type relationship mana to many - "Recipe Ingredients" w/ custom field - "quantity"

Recipe Post - "Basic wooden axe"
Item Post - "knotwood"
Relationship between "basic wooden axe" and "knotwood" - quantiy 3

View template:
content selection: items
[wpv-post-title] x [types field="quantity"][/types]

example url:
hidden link

It shows the post title, but not the quantity. If i add the relationship to the content selection on the view, then it shows the title of the relationship multiple times, as well as the item name, but still no quantity.

Here is the relations ship of the data with example data:

Recipes using items as ingredients. The items can be used multiple times in the same recipe. The items can be in multiple recipes. There can be multiple combinations of items for a recipe. The recipe then makes an item that can be used in another recipe.

Example:

Recipe #1: basic wooden axe
Possible combinations of items for this recipe:
knotwood x 3
knotwood x1, ash wood x1, spruce x1
ash woode x 2, spruce x1

Recipe #2: Advanced wooden axe
Possible combinations of items for this recipe:
basic wooden axe (from the other recipe) x1, magic dust x 5
knotwood x 3, magic dust x 5

What am i doing wrong that I can't get the quantity to display correctly?

Thanks!

#2117297

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Hello and thank you for contacting Toolset support.

Let me try, first, to answer your question What am i doing wrong that I can't get the quantity to display correctly? then I'll comment a little on the current relationships.
The view that will display the items and quantities needs to query the relationship intermediary post instead of the Recipes or Items posts. That way, you can get the correct quantities. And you will need to use the item attribute to get the child item involved in this ingredient. Check this article https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/
It should be something like, assuming that the relationship slug is "recipe-ingredients":

[wpv-post-title item="@recipe-ingredients.child"] x [types field="quantity"][/types]

Now, because you said that The items can be used multiple times in the same recipe, a many-to-many relationship would not work, because it will let you connect one recipe to one item ONLY ONE time.

Toolset does not support the same post type relationships, so you can't link a recipe to another recipe to be able to get The recipe then makes an item that can be used in another recipe
So, this will likely need an additional custom post type to make the link. I can't suggest right now a solution, because I feel I still need to understand your use case further. But, I hope this will give you some insights and let you see Toolset relationships better.

Let me know your feedback, and if possible add another example or add any comments you see can be helpful for me to understand and we'll get to a solution.

#2119953

Ok, that looks like it may be working to some degree. Thanks.

There appears to be a ghost entry of some sort though, just showing an x, like below:

Knotwood x 3
x

Could this be from deleting a previous entry?

#2120023

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

I can't really tell where the 2nd x comes from without checking. Can you add the following code to the view to get more info:

[wpv-post-id] x [wpv-post-type]

I'll need to log into your website and check this closely to better understand what happens. Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

#2120189

Ok, that helped find the culprit. It was the trashed post.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.