Skip Navigation

[Resolved] Big problem for small problem

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

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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: Asia/Kolkata (GMT+05:30)

This topic contains 21 replies, has 3 voices.

Last updated by Minesh 6 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#631714

Hello,

I am creating a big project with Toolset and I have problems that prevent me from starting.

Here is the structure. I have two CPT:
Neighborhoods
Houses

The neighborhoods have custom fields and houses too.

My problem is that
- I would like to be able to display the neighborhoods according to the fields of the houses.
- I would like to be able to display neighborhoods by the fields of houses and neighborhoods
- I would like to be able to display neighborhoods and houses according to the fields of houses and neighborhoods

Someone from Toolset told me that we could not with WordPress make a query on two custom post type at the same time and filter with fields of each CPT, I find it very strange. He therefore advised me to add all the fields of the neighborhoods in the houses and to sort only by house's fields. I find it really strange and not clean.
With sql it is very simple, like this :
SELECT * FROM neighborhoods, houses
WHERE neighborhoods.id = houses.id AND houses.color=red AND neighborhoods.size=big

For starters, I would like confirmation, because I would not want to build such a dirty structure on bad advice.
If it is right, first i think, WordPress, is very bad, because with a lot of recordings, the query will be to slow...

Then, if it was the only solution, I see two problems with this method that could arise.

1) How to display houses grouped by neighborhood?

2) If one day a new field is to enter the neighborhood or even if there is a modification of a field to do on the neighborhood, it will mean that I have to do it on all the houses? If there are 100 or 1000, it's a lot of work for a small and frequent problem. Will there be a solution to change all fields easily?

Thanks a lot for your help.

#631838

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - I see Luo have handled your previous ticket regarding the same issue and what Luo said for WP_Query class is correct. You can not query two post types at the same time as its not allowed by WordPress and Toolset follow strictly WordPress standards.

Basically - when you create a view - you can add filters to it based on the post type it's attached. So, for instance, if view is attached to houses post type, you can filter this view by custom fields, taxonomies attached to houses post type.

What would be the relationship between neighborhood and houses? Many to Many? or One to Many?

If you are not aware, let me tell you that we are going to release new version of M2M relationship where you can add custom fields to intermediary post type for Many to Many relationship. See the Doc:
=> https://toolset.com/documentation/post-relationships/

You should check and see what we offer and if that help you to build your required structure. you should download the Beta plugins from your account's download page (Select "Beta" from top left dropdown) and try to play with it that will give you better idea what you can do and what you can not.

Please note that we are on Beta yet and we are yet to release the stable version for this new M2M relationship but it will not take too long now but there is no ETA. Maybe in mid of next month or end of the month.

1) How to display houses grouped by neighborhood?
==> To group the houses based on neighborhood - you can use nested view to display houses and neighborhood.

See this post - its group by category (taxonomy) but it will give you a little idea, how you can do it.
=> https://toolset.com/2015/07/how-to-group-posts-by-category/

2) If one day a new field is to enter the neighborhood or even if there is a modification of a field to do on the neighborhood, it will mean that I have to do it on all the houses? If there are 100 or 1000, it's a lot of work for a small and frequent problem. Will there be a solution to change all fields easily?
=> You may need to run a custom script or you should add a script to "save_post" action, so when you save entry - it should be duplicate the value to another post type. There is no native solution available for this.

#631905

Thanks for your answer. I repply.

You wrote :
1) How to display houses grouped by neighborhood?
==> To group the houses based on neighborhood - you can use nested view to display houses and neighborhood.

See this post - its group by category (taxonomy) but it will give you a little idea, how you can do it.
=> https://toolset.com/2015/07/how-to-group-posts-by-category/

BUT :
In this case, the main view is parent post. Or un my case, the main view is child post because i have to filter by it. So i don't think it is the same. ?

Thanks for your answer.

#631906

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - you can display the related parent information on child post. So - if you make a view for your child post and if you want to display related parent information it's possible.

See this Doc:
=> https://toolset.com/documentation/user-guides/displaying-fields-of-parent-pages/

#632153

If think we don't understand each other.
Ok i can display parent information, but how i can group by neighborhood...

Because i have to filter by bouse, my view list all houses, but how i can group by neighborhood.

neighborhood 1
house 1
house 2
house 3
house 4

neighborhood 2
housde 1
house 2
house 3
etc...

-----

And you wrote me about new relationship, i have read a lot, it is great, but for me that i understand it is not useful, because my relationship is one to many

Thanks a lot

#632733

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - that needs a bit workaround - there is no direct way.

The thing is that you can easily display this structure using nested view but the thing is that you are using filters for your child view.

If you use nested view without having search - its possible, where parent view will loop through the parent post and child view will loop through the child posts and add the child view within the loop output section of parent view.

#633178

OK thanks, you don't really answer at my first question, and my second question i think you didn't see it, whatever....

I am almost ready to start my big project and i almost am a champion with Toolset, but i would have again some issues. The lasts. I promise.

1) When i use the field adresse : on the wordpress Admin it is a classic field, and on a CRED form it is Google map field.
And my question is when we put a complet adresse in those fields, could we display, after, on the website : the zip code, city etc... ? OR if we need this fields (city, zipcode etc...) we must to create specific field ?

2) Maybe i could use new relationship, but i tried to play with it and it didn't work.
On this view : hidden link
I don't even see the filter.
Question : why ?
Can we use filter on the relationship field on the view ?

After that, i think it will be ok for me.

Thanks a lot

#638718

Nigel
Supporter

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

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

Hi there

Minesh is sick today, hopefully he will be able to reply tomorrow if you have any outstanding questions.

Let me just note with regard to Q1 that the implementation in the beta is currently incomplete, and that filtering by fields of the intermediate post type (or fields of related posts) is due to be added.

Regarding Q2, note this answer I gave some time ago to help another user automatically extract content from the full address returned by the Google API into separate fields: https://toolset.com/forums/topic/separating-content-from-the-address-field/

#641055

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I'm back to work today. I hope Nigel answer your questions.

#641753

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I'm back to work today. I see the shared FTP access details not working again today. Could you please share working FTP access details.

I have set the next reply to private which means only you and I have access to it.

#642177

Hi,

Nigel said "filtering by fields of the intermediate post type (or fields of related posts) is due to be added."
What does that mean ? When it will be work ? One day, one week, one month ? Because i create a project and i will manage it according your answer.

For the Q2, that i understand is with Nigel's code if i add a postcode field it will be fill automatically ?

Thanks a lot.

#642218

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Nigel said "filtering by fields of the intermediate post type (or fields of related posts) is due to be added."
What does that mean ? When it will be work ? One day, one week, one month ?
==> We are about the release the stable release with Many2Many - so you can expect this feature added in couple of months after we release our stable M2M version. This is the first feature our Devs is looking to add to next release after we release stable M2M - M2M stable release you can expect by mid of next month or end of next month.

For the Q2, that i understand is with Nigel's code if i add a postcode field it will be fill automatically ?
=> Yes - the post_code value will be filled automatically - you need to create post_code field accordingly or use field slug correctly.

#642253

But he said " the intermediate post type (or fields of related posts)"
"Or fields of related post", that mean we could filter without relationship ? Just with parent relation ?

I asked that because i'am really not sur i must use the relationship manytomany, because, ok if in the futur we could filter by field it will be help me, but my post is not manytomany, is onetomany and i am afraid that that choice will have bad consequences on my project.
So if in the futur like Nigel said, we could filter even on fields of related posts it will be perfect, but what mean fields of related posts, i am not sure.

Thanks a lot.

#642284

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes - you can filter by custom fields and even display related posts as well as related child posts:
=> https://toolset.com/documentation/post-relationships/

Please check "Post Relationships" box as right sidebar.

Nigel told about "filtering by fields of the intermediate post type" not about related posts. I would suggest you should go through the new Doc of M2M relationship I shared above as well as download Beta version of Types and View's from your accounts download page and try to play with it so you will know exactly what filters available for now.

#643322

I have already read and try to play with the futur M2M and i have seen that :
----
A quick glance suggests you should always use many-to-many relationships. Although one-to-many seems to be a particular case of many-to-many, this is not the case. Understanding the difference and choosing the right relationship for each case is crucial.

The WordPress “page parents” are a good example of one-to-many relationships. Pages can have one “parent” and a parent can have many “children.” A page cannot have more than one parent.
----

So i don't understand why you advice me tu use that, because in my case it is not M2M but O2M

So what is your advice....