Skip Navigation

[Resolved] Order Relationship

This support ticket is created 5 years, 1 month 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
- 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 9 replies, has 2 voices.

Last updated by christopheV-2 5 years, 1 month ago.

Assisted by: Nigel.

Author
Posts
#1352313
liste-detail.png

Hello,

I have woocommerce products (matches) with a relationship type (teams)

In my product I have 2 connected teams.

In my product title I have a home team - outside team

My problem is that these teams are not displayed in the correct order

In my view matches :
<td class="match">[wpv-view name="liste-detail"]</td>

In my view liste-detail :
[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<wpv-loop>
<span class="equipe">[wpv-item index=1]
[wpv-post-title]</span>
[wpv-item index=other]
- <span class="equipe">[wpv-post-title]</span>
</wpv-loop>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-items-found]
[wpml-string context="wpv-views"]No Teams[/wpml-string]
[/wpv-no-items-found]
[wpv-layout-end]

Is it possible to choose a connection date order of the relationship ?? or other possibility ?

Thanks

#1352571

Nigel
Supporter

Languages: English (English ) Spanish (Español )

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

Hi there

From your question I'm not quite sure I understand how you want the child teams to be ordered.

You have a product post (a match) and you connect two existing team posts? Or add new team posts? And what should determine their order when output by the View?

#1352575
import.jpg

When I import products (matches) with wp all import (see attached file) I connect 2 teams
Example code: {equipedomicile[1]},{equipe_visiteur[1]}

I would like the view to be in the same order as this:
equipedomicile - equipe_visiteur

Thank you.

#1352839

Nigel
Supporter

Languages: English (English ) Spanish (Español )

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

Is there anything that identifies the home team as the home team and the visiting team as the visiting team?

The timestamp when a connection is made isn't saved in the database, and even if they were they would be the same if the two connections were made more-or-less simultaneously via an import.

The relationship is a many-to-many relationship? Does it involve and intermediate post type (to store relationship fields)?

If that were the case then—assuming the import routine behaves consistently—the IDs of the generated intermediate posts could be used to establish the order. But you would have to modify your View so that it queried the intermediate post type instead of the team post type (but could still output fields from the related team posts by specifying that relationship as the source in the Post Selection tab when inserting fields using the Fields and Views button.

#1353155
intermediary.png

Hello,

On this print screen will this help you better understand?

Thanks

#1353799

Nigel
Supporter

Languages: English (English ) Spanish (Español )

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

OK, so you do have an intermediate post type (to store the relationship fields), so it might work.

If you didn't specify that the intermediate post type should be visible in the WP admin then the first thing you will need to do is to go to Toolset > Post types and edit the options for the intermediate post type and specify that it is "publicly queryable".

You can then create a View that queries these intermediate post types (it should now appear in the Content Selection).

Add a Query Filter for the post relationship (the exact choice depends on where you will be displaying this View).

For the orderby option choose by Post ID.

To recap, you connect two teams to the same product. With each connection, an intermediate post is created. Because they are created at the same time during an import they are likely to have the same post_date, so cannot be differentiated based upon when the post was created. But these intermediate posts will have distinct post IDs. The View will query and return these intermediate posts, ordered by ID.

In the output section, what do you want to display? If you want to display the names of the teams, for example, then you would use the Fields and Views button to insert the post title, and in the Post selection tab choose the related team as the source for the title.

#1354007
view-match.jpg
content-template.jpg

Ok I could do all the steps, I understood but for query filter I do not know what I have to put?

Thank you

#1354099

Nigel
Supporter

Languages: English (English ) Spanish (Español )

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

That all looks correct, although you could explicitly specify the relationship in your Query Filter (rather than "Any").

Does it not work?

If not it suggests maybe there is a problem with the data, rather than the View.

#1354295
produit-equipes.jpg

It works apparently but I have 2 questions:

Why do I have a team on the post intermediate?

I have 23000 products why I only have 7 intermediate posts? when does this create an intermediate post?

Thank you

#1354575

I use custom field connect with team.

Thanks