Skip Navigation

[Resolved] Parametric search issues with multiple parameters

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 20 replies, has 3 voices.

Last updated by martinE-4 9 months, 3 weeks ago.

Assigned support staff: Nigel.

Author
Posts
#1547673

The page at hidden link shows a view with custom posts and a parametric search section at the top.

Scenario 1:
with a Search button:
"Update the View results only when clicking on the search button"
and
"Always show all values for inputs"

Problem:
1. the "Country" pull-down select shows countries (such as Canada) not in alphabetical order?

Scenario 2:
Ideally, I would like to not have a Search button:
"Update the View results every time an input changes"
and
" Always show all values for inputs"

Problem with scenario 2 (go ahead and edit the view to change the search options to match scenario 2):
2. Initially the search filter area displays correctly. However, as soon as you click on a Type or Discipline, the pagination is shown twice (also the search button but presumably we could just remove it) - and also problem 1 is still present, namely countries NOT in alpha order in select.

Scenario 3: (what I would really prefer to have on my site)
"Update the View results every time an input changes"
and
"Show only available options for each input"

Problem with scenario 3:
3. Initially the search filter area displays the incorrect values for Discipline:
Expected: Theatre / Multidisciplinary / Music / Dance / Visual Arts / Digital Media
Displayed: Multidisciplinary / Music / Visual Arts (missing 3 values)
Additionally, if you click on Discipline="Music" for example, you get the double pagination showing again.

4. As you proceed to test this scenario (3), for example, click on Country 'Spain', all the options for Type disappear? And if you de-select Discipline="Music", all values for Discipline disappear?

I would really appreciate help getting Scenario 3 to work (ie. no search button and show only available options - with no duplicate pagination).

many thanks.

#1548143

Nigel
Supporter

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

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

Hi Martin

1. the countries are shown in the same order as the options are added in the backend when editing the Address Fields post group (screenshot). You can manually re-order the options in the backend and that should be reflected in the frontend.

2. that looks to be caused by broken markup in your Search and Pagination section (the extra closing div shown by the code highlighter, see screenshot).

Can you check if when you fix that you still have the problems described in 3., then I'll look into them.

#1548601

1. I'm embarrassed I forgot about this country list in the back-end. Sorry

2. I removed the </div> (sorry again) and the double pagination disappears.

I removed the Submit button in preparation for getting this to work without it, but problem 3 / 4 with incorrect options for Discipline still occurs (even if I select the 'Disable' option rather than 'Hide' for checkboxes).

So I still need help for this problem. Thanks so much, Nigel.

#1549849

Nigel
Supporter

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

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

I can see that the Type and Discipline checkboxes disappear when making selections for, say, City and Country. Concretely, if I choose Belfast, there is one matching post, and it does have values for Type and Discipline, so those options should still be shown.

I created a fresh test site and tried to reproduce the problem, but I couldn't.

I went back to your site and, on a hunch, I re-saved the directory listing post that is returned when Belfast is selected (post ID = 645), and then sure enough the View worked when I tried the same again.

I'm guessing you imported the data and something (I'm not sure what) is missing, and it's resolved by saving the posts.

Can you try a few posts and confirm if you see the same?

#1550081

Hi Nigel. Brilliant! This indeed is the case! I verified it myself by individually updating a couple of posts. And I did import all my posts (this was a migration from Drupal to WordPress with the FG Drupal to WordPress plugin.

I tried to do a WordPress bulk update in the admin (on South Africa posts) but it didn't work (no effect on the recognition of the checkbox fields, Discipline or Type) - I tried a straight bulk update, then a bulk update by selecting "Published", then I bulk changed the 'Caption' category to 'News' - no effect. Funny that it just seems to be a problem with those checkbox fields, Discipline or Type.

Do you know of any way to bulk update - resave in a way that would make the Types Checkbox fields happy?

I googled a function:

function update_all_posts() {
    $args = array(
        'post_type' => 'directory_item',
        'numberposts' => -1
    );
    $all_posts = get_posts($args);
    foreach ($all_posts as $single_post){
        $single_post->post_title = $single_post->post_title.'';
        wp_update_post( $single_post );
    }
}
add_action( 'wp_loaded', 'update_all_posts' );

from: https://wordpress.stackexchange.com/questions/294575/how-to-force-update-all-posts-after-import

But I'm not sure - (I don't really know what is going on here...what is it about Toolset Types checkbox fields that makes them so special here??...)

#1551989

Nigel
Supporter

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

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

For one thing, you would only need to run a script once, and you can do that when adding snippets to Toolset > Settings > Custom Code.

As for the script itself, I'm not sure if something specific is required (otherwise I would expect the bulk update to work), so I've pinged the developers to check, and I'll get back to you.

#1552155

Nigel
Supporter

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

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

Martin, the developer has asked me for a copy of your site, which I'm taking now, so that he can look and try to identify what's missing from the import that requires a save of the post.

I'll update again when they've had a look at it.

#1552535

Sounds great Nigel. Thanks so much (stay healthy during this terrible pandemic!)
- Martin (Vancouver, BC)

#1553587

Minesh
Supporter

Languages: English (English )

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

Nigel is having a holiday today. He will get in touch with you as soon as he back to work tomorrow.

#1560387

Nigel
Supporter

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

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

Hi Martin

the feedback from the developer is that the checkboxes fields are not saved in the correct format (slightly wrong, but still wrong), so the question is how was this data generated/imported?

Unfortunately, it looks like the posts have to be saved manually, saving the checkboxes field correctly depends on information contained in the $_POST object, which would be missing if we tried to run a script that triggered some update action.

#1560417

Thanks so much for helping me as far as you have. I will tell the maker of the FG Drupal to WordPress plugin the issue since that is how the posts were imported. It is a shame such a great plugin has this error in it. I'm sorry to have wasted so much time of you and the devs. (and myself). I may work my way through to manually save the 400+ posts since that seems like the only solution...

If you have any extra technical info that might help the developer fix this data problem (who promotes the use of Toolset Types for the Drupal to WordPress migration process with his plugin), please let him know. hidden link
or copy me and I will also email him.

Again many thanks for tracking down what must be a frustrating end to this weird issue.

#1560597

Nigel
Supporter

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

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

According to the developer

This is how it is saved, wrongly:
a:1:{s:64:"wpcf-fields-checkboxes-option-d6b258792ff06f82933c74eeb8aef591-1";s:12:"Organization";}

This is how it should be saved:
a:1:{s:64:"wpcf-fields-checkboxes-option-d6b258792ff06f82933c74eeb8aef591-1";a:1:{i:0;s:12:"Organization";}}

I'm finished for today, but if I have time in the morning now that I see what the problem is I'll see if I can advise you on a script to fix it.

#1560599

Thanks Nigel, I have emailed this info to Frederic Gillies the developer of the plugin in the Netherlands. Stay healthy in London? I'm in Vancouver BC and we have quite a lot of cases. Everybody is under voluntary social distancing at home.

#1562269

Nigel
Supporter

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

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

Hi Martin

I didn't reply as the developer said he would give it some more thought.

He did, and decided that if Types understands the field saved in that format (which it appears to), then Views should too.

So he is making an update to Views. We are just about to release version 3.1.3, and he can't produce a patch for you until that happens, but the fix is prepared, so I should be able to pass it on to you shortly afterwards. I'll be in touch.

#1563087

Thanks Nigel! This is great news. I held off doing anything manual with my 490 records so I'm happy. Tell the dev I'm delighted!