Is it possible to combine att tags dropdown + checkboxes ?
-
Now that I have a working gallery with Att. Tags checkboxes with multiple selection enabled, I want to add a new filter also on Att. Tags but with a dropdown and not checkboxes.
For my example, my pictures have colors registered in Att. Tags like this: “RAL 3003”. I want to make a dropdown with custom values (not generated one), and when I select one I want the gallery to be filtered with this att. tag value but also taking consideration of att tags checkboxes. I do not want the filters to cancel each other out.
Is there a way to do that ? To be honest, I have no idea how to do this and have no codes to show apart from this one:
<form id="mla-search-form" action="." method="post"> <strong>Tags</strong> [mla_term_list taxonomy=attachment_tag use_filters=true mla_output=checklist mla_markup=custom-term-list-checklist mla_option_value="{+slug+}" show_count=true pad_counts=false ] <input id="reset" name="reset" type="reset" value="Effacer" /><input id="submit" name="submit" style="float:right;" type="submit" value="Rechercher" /> </form> <h3>Résultats</h3> [mla_gallery] attachment_tag="{+template:({+request:tax_input.attachment_tag+}|no-term-selected)+}" tax_operator=AND mla_markup=custom-gallery link=download mla_nolink_text="Aucun résultat." [/mla_gallery] <input id="base-image-download" style="float: right;" type="button" value="Télécharger les images sélectionnées" /><input id="base-image-clear" style="float: left;" type="button" value="Désélectionner tout" />
-
Thanks for starting this new topic and for posting the text of your form and shortcodes.
It looks like your two-filter application is similar to the one discussed in this earlier support topic:
Dropdown filter with two different taxonomies
Your application does not need the “Category Search” dropdown or the “Keyword Search” in the earlier topic; just the two “Tag Search” filters. You also want one to be a checklist and the other to be a dropdown. Is that right?
You wrote “I want to make a dropdown with custom values (not generated one) …” I am not sure what that means. If you want the dropdown filter to have ONLY the colors you can use the
include
parameter to limit the dropdown to only those terms. You can use theexclude
parameter to remove the color terms from the checklist to avoid confusion.Your
[mla_term_list]
shortcode has ause_filters=true
parameter, which is used by the “MLA UI Elements Example” plugin; have you installed and activated that example plugin? It will improve your application by making the selected term(s) “stick” when the page is refreshed.Here is an updated version of your form with the two filters:
<form id="mla-search-form" action="." method="post"> <strong>Tags</strong> <div> [mla_term_list mla_output=checklist use_filters=true taxonomy=attachment_tag exclude="116,117,118,119,152" show_count=true mla_option_value="{+slug+}" mla_control_name=tag1 mla_item_parameter=current_tag1] </div> <div> [mla_term_list mla_output=dropdown use_filters=true taxonomy=attachment_tag include="116,117,118,119,152" option_all_text=All option_all_value=all show_count=true mla_option_value="{+slug+}" mla_control_name=tag2 mla_item_parameter=current_tag2] </div> <input id="reset" name="reset" type="reset" value="Effacer" /><input id="submit" name="submit" style="float:right;" type="submit" value="Rechercher" /> </form> <h3>Résultats</h3> [mla_gallery] attachment_tag="{+template:({+request:tax_input.attachment_tag+}|no-term-selected)+}" tax_operator=AND mla_markup=custom-gallery link=download mla_nolink_text="Aucun résultat." [/mla_gallery] <input id="base-image-download" style="float: right;" type="button" value="Télécharger les images sélectionnées" /><input id="base-image-clear" style="float: left;" type="button" value="Désélectionner tout" />
In the above example I have added
include
andexclude
parameters to show how that is done. You will have to remove them or substitute the term_id values for your color tags.I suggest you experiment with the example to see if I am on the right track. I will leave this topic unresolved until I hear back from you.
Perfect ! Thanks.
It’s absolutely what I was looking for.
However, there is a problem with your code, I tried it and when I change value for dropdown and click on Search, it doesn’t work because it shows me 0 results (whereas there are for sure because the number of elements corresponding to the tags seleccted in dropdown is displayed higher than 0).Any idea ?
Thanks.Edit:
And I just noticed that tags id inexclude
parameter are not excluded frommla_term_list
, is it working for you ?-
This reply was modified 8 years ago by
hjerem.
Thanks for your update and test results. I believe some adjustments to the text I provided will give you better results.
First, I did some testing and found that the
exclude
parameter interacts with thehierarchical
parameter in a way I did not anticipate. Since thehierarchical
parameter defaults to “true” theexclude
parameter is ignored. You can fix this problem in either of two ways: 1) changeexclude
toexclude_tree
, or 2) addhierarchical=false
to your shortcode.Second, you wrote “when I change value for dropdown and click on Search, it doesn’t work because it shows me 0 results” This may be because your term contains accented characters. If so, you can fix the problem by changing your shortcode parameter to:
attachment_tag="{+template:({+request:tax_input.attachment_tag,raw+}|no-term-selected)+}"
Adding the
,raw
format code will prevent accented characters from being removed from the value before it is used in the query.I regret the inconvenience caused by my oversights; thanks for your understanding. Let me know if the above suggestions work for your application.
First, I did some testing and found that the exclude parameter interacts with the hierarchical parameter in a way I did not anticipate. Since the hierarchical parameter defaults to “true” the exclude parameter is ignored. You can fix this problem in either of two ways: 1) change exclude to exclude_tree, or 2) add hierarchical=false to your shortcode.
It’s working as expected now, thanks.
Second, you wrote “when I change value for dropdown and click on Search, it doesn’t work because it shows me 0 results” This may be because your term contains accented characters.
I don’t have accent in my term names, but I figured out the problem. When I select “All” in dropdown values, it breaks the search (query) because I always have 0 results even if I select a term in
mla_term_list
. I want the filters to be optional, how to do that ?
I searched documentation for theoption_all_value
because I think it’s what I am looking for but there is no info on that plus it’s already defined asoption_all_value=all
which should do what I want right ?I regret the inconvenience caused by my oversights; thanks for your understanding.
The inconvenience ? You are helping me a lot, thanks ??
P.S.
Also, I had a problem with wp_texturize, used a lot in your plugin, I removed it in some of the files of the plugin. I will explain it in another post when I have time.Thanks for your progress report. I will look into the handling of the “All” value, but I want to confirm that you have installed and activated the “MLA UI Elements Example” plugin. At this time, handling of the “All” value is done in that plugin, not in the core MLA logic. Are you using that example plugin?
Are you using that example plugin?
Yes I am. In fact,
use_filters=true
wouldn’t work if I didn’t installed plugin right ?Thanks for confirming. I just re-tested and the “All” option is working on my system. Can you re-post the entire content of your form and shortcodes so I am sure I am testing the same values you are using? Thanks for your patience.
Sure.
Thanks for your patience. You are helping me in a totally free way.<form id="mla-search-form" action="." method="post"> <strong>Tags</strong> <div> [mla_term_list mla_output=checklist use_filters=true taxonomy=attachment_tag mla_markup=custom-term-list-checklist exclude="1412,1397,1519,1398,1395,1455,1461,1389,1390,1456,1407,1431,1409,1434,1377,1378,1426,1379,1403,1485,1448,1449,1438,1436,1454,1444" show_count=true mla_option_value="{+slug+}" hierarchical=false mla_control_name=tag1 mla_item_parameter=current_tag1] </div> <div> [mla_term_list mla_output=dropdown use_filters=true taxonomy=attachment_tag include="1412,1397,1519,1398,1395,1455,1461,1389,1390,1456,1407" option_all_text="Toutes les couleurs" option_all_value=all show_count=true mla_option_value="{+slug+}" mla_control_name=tag2 mla_item_parameter=current_tag2] </div> <div> [mla_term_list mla_output=dropdown use_filters=true taxonomy=attachment_tag include="1431,1409,1434,1377,1378,1426,1379,1403,1485,1448,1449,1438,1436,1454,1444" option_all_text="Toutes les hauteurs" option_all_value=all show_count=true mla_option_value="{+slug+}" mla_control_name=tag3 mla_item_parameter=current_tag3] </div> <input id="reset" name="reset" type="reset" value="Effacer" /><input id="submit" name="submit" style="float:right;" type="submit" value="Rechercher" /> </form> <h3>Résultats</h3> [mla_gallery] attachment_tag="{+template:({+request:tax_input.attachment_tag+}|no-term-selected)+}" tax_operator=AND mla_markup=custom-gallery link=download mla_nolink_text="Aucun résultat." [/mla_gallery] <input id="base-image-download" style="float: right;" type="button" value="Télécharger les images sélectionnées" /><input id="base-image-clear" style="float: left;" type="button" value="Désélectionner tout" />
I copied your text into my system and it is working for me. I do not have your
mla_markup=custom-term-list-checklist
custom template, so the problem may be somewhere in the template. Also, I added the,raw
format code to theattachment_tag
parameter.Can you post the source text of your custom template?
You might also try removing the
mla_control_name=tag1
andmla_item_parameter=current_tag1
parameters from your first[mla_term_list]
shortcode. I discovered that multiple selection is not working whenmla_control_name
is present.I copied your text into my system and it is working for me. I do not have your mla_markup=custom-term-list-checklist custom template, so the problem may be somewhere in the template. Also, I added the ,raw format code to the attachment_tag parameter.
Can you post the source text of your custom template?
When I remove parameter, not working either, but here it is:
<[+itemtag+] class='gallery-item [+last_in_row+]'> <[+icontag+] class='gallery-icon [+orientation+]'> <figure> [+thumbnail_content+] <figcaption> <div> <a href='[+downloadlink_url+]' title='Télécharger'> <i class="fa fa-download" aria-hidden="true"></i> </a> <a class='base-image-magnific-popup' href='[+file_url+]' data-rel='magnific-base-image' title='[+parent_title+]' data-file-name='[+file+]'> <i class="fa fa-search-plus" aria-hidden="true"></i> </a> </div> </figcaption> </figure> </[+icontag+]> <p>[+parent_title+]</p> <p><i class="fa fa-arrows-h" aria-hidden="true"></i> [+width+] x <i class="fa fa-arrows-v" aria-hidden="true"></i> [+height+] px</p> <label style='cursor:pointer;'> <input type="checkbox" class="base-image-checkbox" value="checkbox1"> Sélectionner cette image </label> </[+itemtag+]>
You might also try removing the mla_control_name=tag1 and mla_item_parameter=current_tag1 parameters from your first [mla_term_list] shortcode. I discovered that multiple selection is not working when mla_control_name is present.
Done, not working. If I let the two dropdown unselected (All value selected), can’t get at least 1 result.
That’s strange it’s working on your system. Doesmla_debug=true
will help ?Thanks for posting your template; my request may have been unclear. The template you posted looks like the content of
mla_markup=custom-gallery
in your[mla_gallery]
shortcode. What I would like to see is themla_markup=custom-term-list-checklist
template used in your first[mla_term_list]
shortcode.Have you tried removing the two dropdowns to see if the checklist works without them? You can just change the shortcode name to disable them without losing the content, e.g.,
[xmla_term_list ... ]
.You can add
mla_debug=true
ormla_debug=log
to your[mla_gallery]
shortcode. If you send me your contact information I can give you more detailed instructions and an email address where you can send log files and other information. You can use the Contact Us page at our web site:Thanks for your continued help with this interesting issue!
What I would like to see is the mla_markup=custom-term-list-checklist template used in your first [mla_term_list] shortcode.
<[+itemtag+] id='[+selector+]' class='term-list term-list-checklist term-list-taxonomy-[+taxonomy+]'> <[+termtag+] class='term-list-term term-list-checklist-term level-[+current_level+] [+popular+]' id='[+termtag_id+]'> <input name='tax_input[[+taxonomy+]][]' id='in-[+taxonomy+]-[+thevalue+]' type='checkbox' value='[+thevalue+]' [+selected+]> <label class='selectit' for='in-[+taxonomy+]-[+thevalue+]'> [+thelabel+] </label> [+children+] </[+termtag+]> </[+itemtag+]>
Have you tried removing the two dropdowns to see if the checklist works without them? You can just change the shortcode name to disable them without losing the content, e.g., [xmla_term_list … ].
Thanks for the tips, I tried and checklist is working fine. In fact, each filter works fine on their own. They also work fine when all combined. The only problem is when I don’t select a value for one filter, then search is broken and displays 0 results. I would like to make all filters optional. To be clear, if a dropdown is set on “All” or if no item is selected in checklist, they should be ignored for the search. And this is this behavior that I’m not able to reproduce.
You said this behavior was working for you right ? If so, what’s the
value
of the select for theoption
“All” ? Because for me it’s likevalue="all"
and this is the reason why the search is broken.I found that if I change this:
option_all_value=all
by this:
option_all_value=0
It’s working as expected. Can you please make some test ? I don’t understand why is it working for you. But to make this work (
option_all_value=0
taken into account), I needed to change this line inclass-mla-shortcode-support.php
line 3518:
'slug' => sanitize_title( $arguments['option_all_text'] ),
by this:
'slug' => sanitize_title( $arguments['option_all_value'] ),
Otherwise, since my dropdown take
slug
value, it doesn’t take the value ofoption_all_value
parameter, no matter what value I put it in.I hope I am clear.
Thanks for all.
-
This reply was modified 8 years ago by
hjerem.
Thank you for your continued efforts to understand and solve this problem. As I said, I copied your code into my system and it is working without any problems at all. There is some difference between your system and mine that I do not yet understand.
I have some ideas, but I would like to continue this investigation by email and post a summary here when we have resolved the problem. If you send me your contact information I can give you more detailed instructions and an email address where you can send log files and other information. You can use the Contact Us page at our web site:
Thanks for your continued help with this interesting issue!
Thank you for working with me offline to find and fix the problem with your
[mla_term_list]
shortcode. Your first Keyword is completely numeric, and so its slug value is numeric. This is unusual, and there were several places in the MLA plugin and the UI Elements plugin that tested for numeric values and assumed they were term_id values, not slugs. It took some time to find all of these places and work out a more reliable alternative.I have uploaded a new MLA Development Version dated 20170302 that contains the fixes and an updated MLA UI Elements Example plugin. Thanks again for your patience and persistence in working with me on this topic.
-
This reply was modified 8 years ago by
- The topic ‘Is it possible to combine att tags dropdown + checkboxes ?’ is closed to new replies.