WordPress.org

Support

Support » Plugins and Hacks » [Plugin: Query Multiple Taxonomies]Not working with checkbox

[Plugin: Query Multiple Taxonomies]Not working with checkbox

  • Hi,

    I’m using this code for plugin QMT(Query Multiple Taxonomies) with checkbox, but it’s not working:

    $out .=
    			html( 'li',
    				 get_taxonomy( $taxonomy )->label . ': '
    				.scbForms::input( array(
    					'type' => 'checkbox',
    					'name' => $taxonomy,
    					'values' => scbUtil::objects_to_assoc( $terms, 'slug', 'slug' ),
    					'selected' => qmt_get_query( $taxonomy ),
    				) )
    			);

    The code was this originally in query-multiple-taxonomies/widget.php:

    $out .=
    			html( 'li',
    				 get_taxonomy( $taxonomy )->label . ': '
    				.scbForms::input( array(
    					'type' => 'select',
    					'name' => $taxonomy,
    					'values' => scbUtil::objects_to_assoc( $terms, 'slug', 'slug' ),
    					'selected' => qmt_get_query( $taxonomy ),
    				) )
    			);

    Can anybody tell me how to solve this problem?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author scribu

    @scribu

    If only it were that easy… there are several things that need to be changed in order for this to work. Stay tuned.

    Thank you, scribu. I’m surely keeping an eye on this wonderful plugin.

    I noticed that you used $wp_query->get( $qv ) to get the user-required taxonomy values.
    So I think the code must set the $wp_query somewhere after the user selects values from the forms in the sidebar, but where is the code for that? I didn’t find it, could you tell me where is it?
    Thanks in advance.

    Plugin Author scribu

    @scribu

    After trying to implement this, I’m not so sure I understand what you’re trying to do. How should the taxonomy drilldown work with checkboxes?

    I realized that QMT works with radio box:

    $out .=
    			html( 'li',
    				 get_taxonomy( $taxonomy )->label . ': '
    				.scbForms::input( array(
    					'type' => 'radio',
    					'name' => $taxonomy,
    					'values' => scbUtil::objects_to_assoc( $terms, 'slug', 'slug' ),
    					'selected' => qmt_get_query( $taxonomy ),
    				) )
    			);

    So it means it could display the taxonomies with either lists, dropdowns, or radios.
    Instead of those there, what I want to do is to display the taxonomies with checkbox, so the user could select items with value “football” OR(not and) “basketball” under the same taxonomy “ball”.

    Has anyone revisted this?

    Just to further clarify, we’re looking for an option to replace the hyperlinks in the “list” form with checkboxes. So the widget options for Mode would be “lists, dropdowns, checkboxes”.

    The checkboxes mode would output similarly to the lists mode, but instead of plus and minus signs it would use checkboxes.

    With the method WP uses to handle queries at the moment it is not possible to use checkboxes easily. It effectively would require writing a query translator, WP expects requests for multiple items to be in the format of taxonomy_name=slug1,slug2,slug3, which is not possible with checkboxes (checboxes, all using the same name would look like: taxonomy_name=slug1&taxonomy_name=slug2&taxonomy_name=slug3).

    Javascript could be used to manipulate the query pre-submit, but that’s not very elegant.
    jQuery(':checkbox:checked').map(function() { return this.id }).get().join(',');

    So is it possible to select multiple terms per taxonomy when shown as dropdownbox or checkboxes?

    I have a taxonomy called “Cities” and terms are Paris and New York.

    And what i’d like to do is that when i select both Paris and New York and then click Submit button, i would like to be able to show both Paris and New York related posts in search result page. Is it possible?

    The best implementation would be to offer a submit button OR use an Ajax query to automatically update the query on every checkbox change. Integrating Ajax with a WP query doesn’t seem very simple though.

    @adige72 at the moment what you want isn’t possible, I am planning on contributing some code to rectify this, but I won’t have time for at least another month

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Plugin: Query Multiple Taxonomies]Not working with checkbox’ is closed to new replies.