Skip Navigation

[Résolu] Need Help With Many-to-Many Relationships

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

This topic contains 46 réponses, has 3 voix.

Last updated by Ed Il y a 7 années.

Assigned support staff: Waqas.

Auteur
Publications
#321343

Ed

I honestly don't believe we're on the same page.

I don't ever want to display a "Multiple City Area". I only want to display/view Cities, States, and Listings. The listings must be attached to a City. Listings can also be attached to a State. Listings can also be attached to a single Multiple City Area or multiple Multiple City Areas, without the Multiple City Area ever being displayed.

#321376

Yes, sorry i said display "Multiple City Area", i should said "call" instead. You need to call them because they are your link between city and listing.

You should also make new post type as intermediary post between listing and states. (wihich will be child of listing and states)

I understand your confuseness as it not a easy concept at first glance.

I can try to explain you further. But im sure demo site of Waqas will be a better help.

#321385

Ed

I think my problem with the concept is that I want a "Dallas" listing to display when viewing the City, "Dallas", and I also want to display the listings in a number of cities surrounding Dallas, which belong to the "Dallas Area" intermediary post (which is attached to multiple cities).

I don't want, as intermediary posts:
Dallas Area 1 (with one city)
Dallas Area 2 (with one city)
Dallas Area 3 (with one city)
(one for each city I want to include in the group)

#321420
img.jpg

Sorry im confused too ...

Can you look at theimg attached and tell me if it is what you try to achieve

#321429

Ed

Yes, that looks about right.

We'll have "CityGroups" and (eventually) "StateGroups" which will contain multiple cities and multiple states, respectively.

Optimally, a listing must belong to a city, but could also belong to multiple cities (and states) or multiple CityGroups or StateGroups.

#321434

Ed

Would it be easier to create different post types for each listing level (City Listing, Multi-City Listing, State Listing, Multi-State Listing)? I had actually already started doing that, but reversed course.

#321442

Ok, thank you for your patience, but its quiet complex as there will be a lot of relationship between many post type.
i think every thing must be really clear first before to go deep in a wrong way.

Lets say
Dallas belongs to Texas
And "listing 1" belongs directly to Texas
Do you want to see listing 1 in Dallas view ?

#321445

Ed

Yes, but it could/would be displayed in a separate view, below the more local (City) listings and the listings belonging to the "Dallas Area" CityGroup.

So it would be displayed as:
City listings (if any)
-------------------------
CityGroup listings (if any)
-------------------------
State listings (if any)(optional)
-------------------------
StateGroup listings (if any)(optional)

#321446

Ed

Side note: All the listings above City level will be premium listings and I want to keep everything as automated as it can be.

#321460

Ed

As for the StateGroups, I might want to add one called "Desert Southwest 1" and add the States "Arizona" and "New Mexico". Listings belonging to that StateGroup would be displayed when viewing either of those states (under StateGroup listings) or when viewing Cities in those States.

I might later want to add a StateGroup called "Desert Southwest 2" and add the States "Arizona", "New Mexico", "Texas", and "California", with the same requirements as "Desert Southwest 1".

I don't want to display any listing twice on one page.

Since each listing must belong to a City (before it can belong to anything above it), I only want it displayed at it's lowest level. If you're viewing the City of "Dallas", which resides in the State of "Texas", and a Listing belongs to "Dallas" AND "Dallas Area 1" AND "Texas" AND "Desert Southwest 2", I want it to be listed under "City Listings" only.

If you're viewing the State of "Dallas", which resides in the State of "Texas", and a Listing belongs to "El Paso" AND "Texas" AND "Desert Southwest 2", I want it to be listed under "State Listings" only.

Again, the whole StateGroups thing is optional (but I really want it).

#321461

Ed

And, Waqas, I'm not trying to move the goal post on you. If we can get the first part figured out, I think I can take care of the second part.

#321592

Waqas
Supporter

Languages: Anglais (English )

Timezone: Asia/Karachi (GMT+05:00)

Sorry for being late to the party. After reading all the messages, I just wanted to ask about the use of taxonomies.

@ed, do you think this can be solved with the hierarchical taxonomies? Like categories and sub-categories.

For example, city taxonomy:

- Texas
-- Texas Area 1
-- Texas Area 2
...

So a listing can be attached with any of these. And you can query (using Views) for a particular term or for child terms. There can be separate taxonomies for States but I guess a hierarchical taxonomy will hold the Parent -> Child -> Grand Child relation, all the way down (up to the city area).

Actually what I understood so far is:

- Show all computer repair listings in Texas (including/excluding suburbs or child terms)
- Texas suburbs (or nearby areas), a.k.a. related listings: query for child terms

Because I think, a many-to-many relation may not be suitable in this particular scenario. I may be wrong, please correct me. Awaiting your reply, thanks.

#321608

Ed

I've already got 13000 cities, as custom posts. I don't think switching to taxonomies is in my future.

#321618

Waqas
Supporter

Languages: Anglais (English )

Timezone: Asia/Karachi (GMT+05:00)

Alright, that makes sense. I will get back to you soon.

#321619

Ed

Thanks, Waqas. I appreciate it.

If I could just figure out how to display Listings, that belong to CityGroups, which contain Cities other than the specific City the Listing resides in, we'd be in good shape.

Grandparents are the CityGroups
Parents are the Cities
Children are the Listings
A City in a CityGroup, other than the parent City, would be an aunt/uncle
The Listings in those other Cities, which reside in the CityGroup, would be nieces/nephews of the current City

I need to figure out how to display Listings as nieces/nephews of the current City

You're viewing the City of "Fort Worth TX". You'll see Listings that belong to "Fort Worth". Below those listings, you would see Listings that belong specifically to the City of "Dallas", but also belong to the "Dallas Area 1" CityGroup, which contains the City of "Fort Worth".

Simplified: I want to give Listings more than one parent of the same post type (City).

...I think.