Skip Navigation

[Resolved] Content in Checkboxes multiplies as if they coose all variables of the

This support ticket is created 5 years, 7 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.10 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: Asia/Karachi (GMT+05:00)

This topic contains 18 replies, has 3 voices.

Last updated by kristenM 5 years, 5 months ago.

Assisted by: Waqar.

Author
Posts
#1225388
Views with filter EconomySystems.jpg
Search filtering page find-en-oekonomispecialist.jpg
page - member - with customfields EconomySystems.jpg

I am trying to make a filter of a searchquery of some data I have imported into pages via WPAllImport.

I have made some filters and some of them works (company, zipcode etc.)

What doesn't work is checkbox searches of some of the multiple choices for instance the field "EconomySystems" where choices are divided by new line.

You can see the result in the uploaded images and I have given you access so you can see it for your self.

Have you any suggestions how to get the filters to work properly?

Thank you in advance.

Kind regards.

Kristen Mathiasen

#1225402

The page where you can see the search is hidden link

#1225409

...and remember to login at first or your are redirected to another page. This is only a test site for the search-page.

#1225570

Hi Kristen,

Thank you for contacting us and I'll be happy to assist.

I've checked the "EconomySystems" field and noticed that it is set as a "Text Area" type field through "Advanced Custom Fields" plugin.

I'm afraid, the way the front-end search filter feature works, it doesn't support using content from the text area type fields (from Toolset or any other plugin) to be used for an individual item/choice based filtering.

If you'd like those choices in the field to be used as front-end filters with checkboxes, you can add a new checkboxes type field through Toolset and then save those items through that field.
( ref: https://toolset.com/documentation/user-guides/using-custom-fields/#how-to-add-custom-fields-to-content )

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1226086
Postfieldgroup MemberID.jpg

Hi Waqar.

Thank you very much for your quick answer.

I have actually tried to build a Post Field Group with checkboxes but I get stuck when I try to figure how I must configure it.

I would like the checkboxes to be created automatically from the data I import via WP All Import but when I try to build a checkbox I understand that I manually have to type the name of each checkbox? The ref: you are referring to don't show me have to do this (or at least I don't understand it then :-))

I have uploaded an image of the Post field group I was trying to build connected to posttype "Medlemmer".

If you have any suggestions to how I can configure this I would be thankful.

Kind regards.

Kristen

#1226358

Nigel
Supporter

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

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

Hi Kristen

Waqar is off today, let me step in.

The checkboxes field in Types is a complex field. You cannot create the options programmatically, you can only do so in the admin pages. But because of how the data is stored, you cannot programmatically assign checkboxes values to posts, either, which means you cannot import posts and set the checkboxes fields options.

We have a feature request to provide an API function to set checkboxes fields programmatically, but for the time being it is simply not possible.

The only viable option I see is to use a single line text field which is repeating, meaning that you can have more than one instance of the field for any post.

You would need to be able to import the EconomySystems data, for example, as multiple single line fields rather than as one multiline field.

That means for a particular post you might end up with wp_postmeta containing two entries, e.g.

wpcf-economy-systems => Dinero
wpcf-economy-systems => Visma

(Types custom fields are stored in wp_postmeta with a 'wpcf-' prefix.)

Then if you create a View to filter such posts, you can choose checkboxes for the format of the filter control, and it will automatically add a checkbox for any value for the field it finds in wp_postmeta.

The remaining problem is that if you check more than one checkbox in the View you will get not results, because the comparison would be EQUALS or LIKE, but what you need is IN.

So you would need to add a little custom code to modify the generated query to use the IN comparison.

I can help you with that, but it only makes sense if you are able to import your data as described above, so I'll wait to hear back from you.

#1226386

HI Nigel.

Thank you for stepping in when Waqar is free.

Just so that I understand your mail correct.

You wan't me to create one field for each line. That would mean that I would create 34 fields alone for EconomySystems and x-number for the rest. That would easily be more than 200 fields.

Is that manageable for the system?

About the little custom code. Where can I get some help for that?

I look forward to hear from you.

Kind regards.

Kristen

#1226435

Nigel
Supporter

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

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

Screenshot3.png
Screenshot2.png
Screenshot1.png

Just to be clear, you create one custom field in some field group at Toolset > Custom Fields and allow it to have multiple instances.

So in screenshot1 I have a custom field "notes" which can have multiple instances.

In the back-end, in screenshot2, I'm editing a post that uses this custom field, and I've added several values.

In screenshot3 you can see how that is stored in the database in wp_postmeta.

One post, with multiple entries for the same custom field (wpcf-task-notes), instead of one custom field with just one entry split across multiple lines (which is how it appears in your screenshot "page - member - with customfields EconomySystems.jpg"

Other posts will have other entries for the field.

If you are able to set up your data in that way, then you can add a View with a search filter for this single-line text custom field but where the filter control is checkboxes.

If you get that far you should find it working when you select one checkbox, but returning no results when you select more than one.

I'm running out of time today but if you can confirm you get the same then I can help with the code to fix the final part on Monday morning.

#1226494

HI Nigel.

Thank you for your quick answer.

I'm looking at it rigth now and trying to get it to work. I'm uncertain if it works because when I read your reply I get the understanding that I'm typing the data manually in to these fields.

I'm not typing manually into these fields but I'm getting the data via WP All Import as JSON-data from an external site.

I'll let you know if I get it to work - and I wish you a pleasant weekend.

Kind regards

Kristen

#1227104

Nigel
Supporter

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

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

Hi Kristen

Yes, in my example I was manually entering the data. It will still work when importing the data, if you can get the data stored in the format shown in screenshot3.png of my previous reply.

#1231448

Hi Nigel.
Sorry the long wait.
I have tried to get it to work - but sadly with no success.
I now try to get the WP All Import to import the checkboxes as actual checkboxes instead of text divided by ENTER.
I will return later with updates.
Kind regards.
Kristen

#1231570

Hi again Nigel.
This time I think I really have made a mess.
When ever I use the search-site it shows the same member - although when I use the text-search I can find a single member. For instance I tried to search "Seize" and it shows only one member - but with wrong search-text.
You can see it here: hidden link

Remember to log in first.

The View I have worked on is "Medlemmer - custom search".

Can you help me to find out what I have done wrong?

Thank you in advance.

Kind regards

Kristen

#1232002

Hi Kristen,

Nigel will be on vacations until next week so I'll be resuming on this ticket.

I've checked the front-end and the back-end of the view ( at hidden link ), but couldn't make sense of "search-site" and "search-text".
( screenshot: hidden link )

Can you please elaborate a little more on what you tried and expected, and instead what happens?

I'll be in a better position to guide you accordingly.

regards,
Waqar

#1232015
Views - Medlemmer - custom search.jpg
page - medlemmer - custom search - same members show.jpg

Hi again Waqar and thank you for taking over when Nigel is on vacation 🙂

I will try to explain what I'm trying to do and what worked before I began to work on the checkboxes that started this support ticket. I have uploaded two screen dumps to help understand the problem.

In the Views of "Medlemmer - Custom search" I wan't to show 4 fields and two buttons:
1. Company (Virksomhed)
2. Zip (Postnummer)
3. City (By)
4. Search (Fritekst soegning)
5. Submit-button (Soeg)
6. Reset-button (Nulstil)

I have also thrown in some pagination so that I don't get over 400 results every time.

At the front-end this View shows a number of members - or they show the same membertext in each row - although it is different members. (See screenshots)

The way I know this is that I cannot use the 3 first search-boxes (Company, Zip and City) without I'm using words that I can see in the search on the front-end. But when I use the search-field and for instance search for "Seize" it only shows one result - which is correct.

The problem is therefor that this View copies the text from one of the members and shows this on all the other members at the front-end.

Do you know what I have done wrong?

Kind regards

Kristen

#1232029

Hi again Waqar.
I may have forgot to mention what I wan't top show on the front-end.

I have build 3 columns that should show the following fields:

1. Image from member (companylogo)
2. Companyname, adress, zip and city (and phone and email)
3. Profiletext

If you have any questions I look forward hearing from you.

Kind regards

Kristen