Skip Navigation

[Resolved] "%5B%5D" characters added to url-param, thus search not showing right

This support ticket is created 6 years, 6 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 11 replies, has 2 voices.

Last updated by Ido Angel 6 years, 6 months ago.

Assisted by: Christian Cox.

Author
Posts
#911486

take a look:

hidden link

after submitting the search, i get this url:

hidden link

notice each search parameter has "%5B%5D" after it (for example: sort-value-heb%5B%5D). and i get all results instead of filtered results
any idea?

thanks!
ido

#911594

Any field that allows multiple selections will be represented as an array in the search URL parameters, this is the expected behavior. %5B%5D is a URL-encoded array notation equivalent to array brackets []. If multiple generes options are selected in the search panel, the URL parameters should look like this:

...&generes%5B%5D=drama&generes%5B%5D=periodic-drama...

So this means both "drama" and "periodic-drama" were selected in the search filters. If the filtered results are not what you expect, please take a screenshot showing all the Query Filters in the View editor screen. Include that image with your next reply and we can review those filter configurations.

#911596

hey, thanks for the explanation ?
and no, the search result ignores the url parameters and simply shows all search results instead of the filtered ones. but only in the first filter, which is "playwright".

in this page -

hidden link

the first dropdown is for choosing a playwright. whatever name you choose, the form reloads with the playwright unchosen, despite the name appearing in the url parameter.

the filters are too many to show in print screen...

here's the link:

hidden link

thanks!

#911600

I'm confused, can you tell me more about this /plays page? Is the /plays URL supposed to be a custom Page with a custom search View, or is /plays supposed to be the Search archive? If it's a custom Page with a View, then the results of the View ID 817 are not displayed anywhere. The PHP template file does not include the results of the View: hidden link
It seems to have a standard loop. A View's filters will not affect the standard loop of posts, they will only affect a View's results.

If you want to output the View using PHP, you should use the render_view API: https://toolset.com/documentation/programmer-reference/views-api/#render_view

If /plays is supposed to be the search Archive, then you should create a Toolset WordPress Archive with search filters, and assign that WP Archive to the Search archive. Then use the Loop Output of that WP Archive to display the filtered results.

#911601

now i'm confused 🙂

this /plays page is a custom search page. the right side is the search filter, the left side is the results. i've done this a million times. just a simple search view for cpt "plays".

this is the results loop:

<style>
  .languages_available {color: #000000 !important}
</style>
<wpv-loop>
 
        <span class="name-link"> [wpv-post-link] / [wpv-post-link id="$playwright"] </span> <span class="taxonomy-link">[wpv-post-taxonomy type="genre" separtor=", " format="text" show="name"] 
        </span> 
 [wpv-if py="wpcf-premiere-year" evaluate="!empty($py)"] | [types field="premiere-year"][/types][/wpv-if] 
         <span class="languages_available">
       [wpv-if f1="wpcf-script-link" evaluate="!empty($f1)"]<strong>➦</strong>[wpml-string context="wpv-views"]he[/wpml-string]
           [/wpv-if] 
        
        [wpv-if fpdf="wpcf-script-pdf" evaluate="!empty($fpdf)"]
          [wpv-if ffull="wpcf-script-provided-is-partial" evaluate="empty($ffull)"]
           <strong>➥</strong>[wpml-string context="wpv-views"]he[/wpml-string]
          [/wpv-if]
        [/wpv-if] 
           [wpv-if ftran="wpcf-sources-of-other-languages" evaluate="!empty($ftran)"]
           | <strong>➥</strong>
             [wpv-post-field name="translated_texts_0"] [wpv-post-field name="translated_texts_1"] [wpv-post-field name="translated_texts_2"] [wpv-post-field name="translated_texts_3"] [wpv-post-field name="translated_texts_4"] [wpv-post-field name="translated_texts_5"]
          [/wpv-if]    
           
        </span>             
  <!--         
        [wpv-if f1="wpcf-script-link" evaluate="!empty($f1)"]<img align="absmiddle" width="19" height="16" src="<em><u>hidden link</u></em>" border="0" class="source_text_icon">[/wpv-if] 
        
         [wpv-if f11="wpcf-script-pdf" evaluate="!empty($f11)"]<img align="absmiddle" width="19" height="16" src="<em><u>hidden link</u></em>" border="0" class="source_text_icon">[/wpv-if] 
                  
        [wpv-if f111="wpcf-script-link-to-buy" evaluate="!empty($f111)"]<img align="absmiddle" width="19" height="16" src="<em><u>hidden link</u></em>" border="0" class="source_text_icon">[/wpv-if] 
        -->
<br>
      </wpv-loop>

 [co_writers_search][/co_writers_search]

could you please try again?
Thanks!

#911830

the left side is the results
Please show me where to find the exact code (PHP or shortcode) that is used to place the results of this View on the page. I found no render_view function to produce the results, and there is no wpv-view shortcode in the Page or template. So I must be missing something. Furthermore, this is an invalid Loop Output structure:

<style>
  .languages_available {color: #000000 !important}
</style>
<wpv-loop>
  
        <span class="name-link"> [wpv-post-link] / [wpv-post-link id="$playwright"] </span> <span class="taxonomy-link">[wpv-post-taxonomy type="genre" separtor=", " format="text" show="name"] 
        </span> 
 [wpv-if py="wpcf-premiere-year" evaluate="!empty($py)"] | [types field="premiere-year"][/types][/wpv-if] 
         <span class="languages_available">
       [wpv-if f1="wpcf-script-link" evaluate="!empty($f1)"]<strong>➦</strong>[wpml-string context="wpv-views"]he[/wpml-string]
           [/wpv-if] 
         
        [wpv-if fpdf="wpcf-script-pdf" evaluate="!empty($fpdf)"]
          [wpv-if ffull="wpcf-script-provided-is-partial" evaluate="empty($ffull)"]
           <strong>➥</strong>[wpml-string context="wpv-views"]he[/wpml-string]
          [/wpv-if]
        [/wpv-if] 
           [wpv-if ftran="wpcf-sources-of-other-languages" evaluate="!empty($ftran)"]
           | <strong>➥</strong>
             [wpv-post-field name="translated_texts_0"] [wpv-post-field name="translated_texts_1"] [wpv-post-field name="translated_texts_2"] [wpv-post-field name="translated_texts_3"] [wpv-post-field name="translated_texts_4"] [wpv-post-field name="translated_texts_5"]
          [/wpv-if]    
            
        </span>             
  <!--         
        [wpv-if f1="wpcf-script-link" evaluate="!empty($f1)"]<img align="absmiddle" width="19" height="16" src="<em><u>hidden link</u></em>" border="0" class="source_text_icon">[/wpv-if] 
         
         [wpv-if f11="wpcf-script-pdf" evaluate="!empty($f11)"]<img align="absmiddle" width="19" height="16" src="<em><u>hidden link</u></em>" border="0" class="source_text_icon">[/wpv-if] 
                   
        [wpv-if f111="wpcf-script-link-to-buy" evaluate="!empty($f111)"]<img align="absmiddle" width="19" height="16" src="<em><u>hidden link</u></em>" border="0" class="source_text_icon">[/wpv-if] 
        -->
<br>
      </wpv-loop>
 
 [co_writers_search][/co_writers_search]

A valid loop contains all these tags and comments:

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
		<wpv-loop>
		</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

You can see that everything but wpv-loop is missing in your Loop Output structure.

#911832
view in page.jpg

hey,

here's the code in the page (see img)

i've added the tags to the loop:

<style>
  .languages_available {color: #000000 !important}
</style>
[wpv-layout-start]
    [wpv-items-found]
    <!-- wpv-loop-start -->
<wpv-loop>
 
        <span class="name-link"> [wpv-post-link] / [wpv-post-link id="$playwright"] </span> <span class="taxonomy-link">[wpv-post-taxonomy type="genre" separtor=", " format="text" show="name"] 
        </span> 
 [wpv-if py="wpcf-premiere-year" evaluate="!empty($py)"] | [types field="premiere-year"][/types][/wpv-if] 
         <span class="languages_available">
       [wpv-if f1="wpcf-script-link" evaluate="!empty($f1)"]<strong>➦</strong>[wpml-string context="wpv-views"]he[/wpml-string]
           [/wpv-if] 
        
        [wpv-if fpdf="wpcf-script-pdf" evaluate="!empty($fpdf)"]
          [wpv-if ffull="wpcf-script-provided-is-partial" evaluate="empty($ffull)"]
           <strong>➥</strong>[wpml-string context="wpv-views"]he[/wpml-string]
          [/wpv-if]
        [/wpv-if] 
           [wpv-if ftran="wpcf-sources-of-other-languages" evaluate="!empty($ftran)"]
           | <strong>➥</strong>
             [wpv-post-field name="translated_texts_0"] [wpv-post-field name="translated_texts_1"] [wpv-post-field name="translated_texts_2"] [wpv-post-field name="translated_texts_3"] [wpv-post-field name="translated_texts_4"] [wpv-post-field name="translated_texts_5"]
          [/wpv-if]    
           
        </span>             
  <!--         
        [wpv-if f1="wpcf-script-link" evaluate="!empty($f1)"]<img align="absmiddle" width="19" height="16" src="<em><u>hidden link</u></em>" border="0" class="source_text_icon">[/wpv-if] 
        
         [wpv-if f11="wpcf-script-pdf" evaluate="!empty($f11)"]<img align="absmiddle" width="19" height="16" src="<em><u>hidden link</u></em>" border="0" class="source_text_icon">[/wpv-if] 
                  
        [wpv-if f111="wpcf-script-link-to-buy" evaluate="!empty($f111)"]<img align="absmiddle" width="19" height="16" src="<em><u>hidden link</u></em>" border="0" class="source_text_icon">[/wpv-if] 
        -->
<br>
      </wpv-loop>
 <!-- wpv-loop-end -->
    [/wpv-items-found]
    [wpv-no-items-found]
        <strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
    [/wpv-no-items-found]
[wpv-layout-end]

 [co_writers_search][/co_writers_search]

still same error...
thanks!

#911916

Okay thank you, I see the view shortcode now. The filter in this View is configured to test a custom field "sort value heb":

[wpv-control field="sort-value-heb" url_param="sort-value-heb"  type="select" auto_fill_default="בחר מחזאי" auto_fill="wpcf-sort-value-heb" auto_fill_sort="asc"]

That custom field is not applied to Plays. It is applied to Playwrights:
hidden link

This is why the filter does not appear to do anything - you can't filter Plays by a field assigned to another post type. Either you should apply this field group to Plays and assign a value in each Play, or you can remove this custom field filter and add a post relationship filter instead.

#912003
plays.jpg

but playwrights ARE conneted to plays!
take a look at the screenshot, from a playwright. there's a play connected to him.

#912018

we have this code in functions.php:

add_action('pre_get_posts', 'theme_register_endpoints');
function theme_register_endpoints($query) {
	global $wpdb; 
	//if($_SERVER['REMOTE_ADDR']=="79.176.10.164") {
	if(isset($_GET["sort-value-heb"]) || isset($_GET["sort-value-eng"])) {
		
		if(isset($_GET["sort-value-heb"]) && $_GET["sort-value-heb"][0]!='') {
			$sort_key = 'wpcf-sort-value-heb';
			$sort_val = $_GET["sort-value-heb"][0];
		} elseif(isset($_GET['sort-value-eng']) && $_GET["sort-value-eng"][0]!='') {
			$sort_key = 'wpcf-sort-value-eng';
			$sort_val = $_GET["sort-value-eng"][0];
		}
		$q = '									
		SELECT element_id 
		FROM  wp_icl_translations 
		WHERE element_id
		IN (

		SELECT ID
		FROM wp_posts
		WHERE ID
		IN (

		SELECT post_id
		FROM  `wp_postmeta` 
		WHERE meta_key =  "'.$sort_key.'"
		AND meta_value =  "'.$sort_val.'"
		)
		AND post_type =  "playwright"
		AND post_status = "publish"
		)
		AND element_type =  "post_playwright"
		AND language_code =  "'.ICL_LANGUAGE_CODE.'"';
			
						
		$pwid = $wpdb->get_var($q);	
		//var_dump( $_GET["sort-value-heb"][0]);
		//var_dump($q);
		$_GET["sort-value-heb"]="";
		$_GET["sort-value-eng"]="";
		$_GET["wpv-pr-child-of"]=$pwid;
											
						//echo $pwid;	
	}
	//}	
}

i think this was done (by another programmer) to allow ppl to edit plays (via cred) in both languages

#912101

take a look at the screenshot, from a playwright. there's a play connected to him.
I understand that, but it does not change how custom search Views work. You cannot filter a View of post type A by a field in post type B, even if the posts are in a post relationship. Those filters must be removed from the Query Filter and the Filter Editor, because they will not work correctly. I can help you troubleshoot any Views API that is not producing the expected results, but this code doesn't use any Views APIs. It's purely custom query manipulation.

#912168

Hey Chris,

Ok - got it. The code was done by another programmer, the purpose was to automatically apply the custom field for english play name to the wpml translated field of the hebrew play name.

i just had to adjust the relationship filter to "playwright" and it seems to work.

Thanks!