Skip Navigation

[Fermé] Types + Views Many to Many Help

This support ticket is created Il y a 7 années et 5 mois. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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)

Marqué : 

This topic contains 19 réponses, has 2 voix.

Last updated by Nigel Il y a 7 années et 4 mois.

Assisted by: Nigel.

Auteur
Publications
#459036

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

Timezone: Europe/London (GMT+00:00)

Hi David

Unfortunately we are having a weather-related internet outage where I live and I am on 3g mobile data as a back-up and it's not up to the task of video calling let alone screen sharing, hopefully that will be resolved soon.

So I took another look in the back end of your site and I see what the problem is.

You are basically doing things right, except you are taking a shortcut with your connectors which are introducing the problem.

You have 3 custom post types, and you are sharing one connector CPT for all of the connections between them.

So here is what happens with your view "Related recipes".

It is querying connector posts. It adds a filter to show connectors that are children of the post where this view is shown. So when you add it to the Workout content template, it will return the connectors for that particular workout.

In your loop output section you use the id="$recipe" attribute to specify that we want to output the content of the parent recipe post to this connector, not content of the connector itself.

That was working when you added your first test workout-recipe connectors.

When you added a connector to connect the Workout to a Rest, then you ran into the problem.

You query gets all the connectors that are children of the current workout. But there is nothing to say that you only want recipe connections. You want two filters for this view that say "get all connectors that are children of the current workout and which also have a recipe post as a parent". But there is no means to add the latter part, and your id="$recipe" failed when the other parent was a rest and not a recipe.

You need separate connector post types for each type of connection.

So you need:

- a recipes-and-workouts post type that connects recipes and workouts
- a rests-and-workouts post type that connects rests and workouts
- a workouts-and-workouts post type that connects workouts with related workouts

plus the same for any other combinations, e.g. connecting recipes to rests

Then for your "Related recipes" view you would query the recipes-and-workouts connector post type with a filter as before to show posts that are children of the post where this view is shown, which you add to your workouts content template, and you use the id="$recipe" attribute to get the content for the recipe parent post.

Your "Related rests" view you be essentially the same, but it would be querying the rests-and-workouts connector post type and you would use the id="$rests" attribute in the loop output.

That doubtless sounds like a lot of hard work but is unavoidable if you want to manually specify your post connections rather than use the random post from a category association I described previously.

The work on Types 2.3 with the changes to how post relationships are handled is still very much work-in-progress as far as I can see from the internal tickets, I'm not expecting it to be released soon.

#459259

Hi Nigel,

Thanks for getting back to me. Okay I think I follow now, however that is complex for me and having a custom post type connector for each connection type means a lot of custom post types, my issue is I have no way of teaching end users how to administer this approach so will have to go back to using a taxonomy approach to showing related posts rather than building actual connections so think I will try that method next and then wait until I do hear news about an improved approach to connecting posts.

There has to be a simpler way so truly hope your team can iron out the kinks and find a more intuitive way of handling this as selecting specific related posts is powerful when it works in an easy way. Most of my clients are technophobes so I have to make things as easy as possible.

Thanks, when the internet is better I would still like to take you up on the screenshare opportunity if possible just so I am 100% sure of how this works.

#459513

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

Timezone: Europe/London (GMT+00:00)

Hi David

Can you think about how you plan to associate the related posts and let me know so that I can think about the implementation?

You have 3 CPTs, Workouts, Rests, and Recipes.

When viewing a Workout, what related Recipes should be shown? We are going to pass on manually setting up the relationships. The loosest connection is basically no connection, that for any Workout you show 3 random Recipes.

You can improve on that by creating some taxonomies and then show 3 of however many Recipes have a matching taxonomy term, e.g. if a Workout is tagged with the term "High Energy" then show related Recipes which are also tagged "High Energy".

You (or your client) will need to think of a few taxonomy terms that can meaningfully connect the different post types (and posts of the same type, e.g. related recipes on a recipe post page).

If you go down that route it is reasonably straightforward to set up, you create a View for Workouts, say, and then add a taxonomy filter such as "Select posts with taxonomy: Categories the same as the current post in the loop".

That's pretty much all there is to it, but think about whether using taxonomies sounds like the right way to go and what those taxonomies might be and let me know.

#462488

Yes the idea is to have recipes and rests that are conducive to specific workouts. So the initial idea was to be able to manually connect these as there are specific ones which work better.

Random ones won't work so I would be left with a taxonomy-based approach where I can find something they can have in common like a tag and then use the tags perhaps as a way to associate them.

I don't honestly understand programmatically why it isn't possible to just assign them without the whole 3rd party connector post type which makes things difficult.

I think the taxonomy needs to be something like "topic" or something, as rests will eventually display related workouts and recipes and recipes will also eventually show related workouts and rests so the taxonomy needs to make sense across the three post types.

I will attempt to implement this and then update you to let you know how I get on. I will do that and then review the new connector based approach that is coming in the near future

Thanks

#462496

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

Timezone: Europe/London (GMT+00:00)

OK, let me know if and when you need some more help.

I'll mark this as waiting for further info from you so that it stays open for a couple of weeks without nagging you.

Le sujet ‘[Fermé] Types + Views Many to Many Help’ est fermé à de nouvelles réponses.