Support » Plugin: Media Library Assistant » Search fields and presentation of results

  • Resolved ernstwg

    (@ernstwg)


    Good morning.

    I like to enter search criteria for attachment cotegories, for attachment tags and free text. Three different options, clearly separated for the user. So far so good. Minor questions popping up but my main question is: how to lead this into one presentation of search results.

    Thanks for your work, Ernst-Wilhelm

    Coding for attachment category, found somewhere in this forum, works fine.

    <form id="mla-text-form" action="." method="post" class="row">
    <strong>Att. Categories</strong>
    [mla_term_list taxonomy=attachment_category mla_output=checklist mla_option_value="{+slug+}" show_count=true pad_counts=false ]
     
    <input id="text-form-submit" name="text_form_submit" type="submit" value="Search">
    </form>
     
    <h3>Gallery</h3>
    [mla_gallery attachment_category="{+template:({+request:tax_input.attachment_category+}|no-term-selected)+}" columns=3 link=file size=large orderby=rand mla_style="experiment-default-basis-top" mla_markup="experiment-default-basis-back-to-post"]
    • This topic was modified 2 months, 1 week ago by ernstwg.

    The page I need help with: [log in to see the link]

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author David Lingren

    (@dglingren)

    Thanks for the kind words and for your question. Combining two or more search criteria to produce a single filtered gallery is a popular idea. Here is an earlier support topic that contains a solution as well as links to other, similar application solutions:

    Shortcode Display Help

    As I wrote there, each application is a bit different and finding the right solution can be tricky. I am confident that studying the earlier topics will give you the information you need for your application. I will leave this topic unresolved for now in case you have problems or further questions regarding the material in the earlier topics.

    ernstwg

    (@ernstwg)

    David.

    I am following the sample code provided at the bottom of Shortcode.

    In the documentation I couldn’t identify expressions as use_filters or add_filters_to, these could be the most promising detail.

    I will look for the other posting. Looking forward to here from you.

    • This reply was modified 2 months ago by ernstwg.
    Plugin Author David Lingren

    (@dglingren)

    Thanks for taking the time to read through and apply the solutions presented in the earlier topics.

    The use_filters and add_filters_to parameters are processed by the “MLA UI Elements Example” plugin. You must install and activate that example plugin to handle them. Here is the “documentation”, which is in the example plugin’s source file:

     * Provides shortcodes to improve user experience for [mla_term_list],
     * [mla_tag_cloud] and [mla_gallery] shortcodes
     *
     * In this example:
     *
     * 1. If you add "use_filters=true" to an [mla_term_list] shortcode this plugin will retain the
     *    selected terms when the page is refreshed and pass them back into the shortcode.
     *
     * 2. If you add "add_filters_to=any" to an [mla_gallery] shortcode this plugin will retain
     *    settings for terms search, keyword search, taxonomy queries and posts_per_page when the
     *    page is refreshed or pagination moves to a new page.
     *
     * 3. If you add "add_filters_to=<taxonomy_slug>" to an [mla_gallery] shortcode this plugin will
     *    do the actions in 2. and will also match the taxonomy_slug to a simple taxonomy query (if
     *    present) and add that query to the taxonomy queries. If the simple query is 'muie-no-terms',
     *    it will be ignored.
     *
     * 4. Shortcodes are provided to generate text box controls and retain their settings when the
     *    page is refreshed or pagination moves to a new page:
     *
     *    [muie_terms_search] generates a terms search text box
     *    [muie_keyword_search] generates a keyword search text box
     *    [muie_orderby] generates an order by dropdown control
     *    [muie_order] generates ascending/descending radio buttons
     *    [muie_per_page] generates an items per page text box
     *    [muie_assigned_items_count] returns the number of items assigned to any term(s) in the
     *    selected taxonomy
     *
     * 5. With a bit of work you can add a tag cloud that works with these filters. Here's an example
     *    you can adapt for your application:
     *
     * <style type='text/css'>
     * #mla-tag-cloud .mla_current_item {
     * 	color:#FF0000;
     * 	font-weight:bold}
     * </style>
     * <span id=mla-tag-cloud>
     * <strong>Tag Cloud</strong>
     * [mla_tag_cloud taxonomy=attachment_tag number=20 current_item="{+request:current_item+}" mla_link_href="{+currentlink_url+}&tax_input{{+query:taxonomy+}}{}={+slug+}&muie_per_page={+template:({+request:muie_per_page+}|5)+}" mla_link_class="{+current_item_class+}"]
     * </span>
     *
    

    Let me know if you have any problems or further questions regarding the example plugin’s parameters. Thanks for your efforts!

    ernstwg

    (@ernstwg)

    My problem is that I can read but very often I only read half of it. So I installed the sample plugin but didn’t activate it. Surprisingly nothing changed. After minutes of sitting and thinking I checked the status and here we go. Great step forward. 🙂 I will work on it and will come back to you. Thank you and have a good day.

    ernstwg

    (@ernstwg)

    David, Good Morning. Your solution looks great and provide great results. One point is confusing, I want to display structured attachment categories to provide the user additional information to find what he is looking for. There are some cases where no images are displayed though it should.

    My impression is, it works well, if I want to display the images on the 3rd level category. There are always three levels. In most of the cases level 1 or 2 does not work, particulary if we have more third level categories. If there is only 1 3rd level cat. it works also for level 2 and 1 cat.

    Deside of this I am not sure if the counting is correct, but I need to check more in detail.

    Many thanks for your work, Ernst-Wilhelm

    Example

    Selection

    <div class="catlist">
     <p>Kategorien, Beiträge</p>
     [mla_term_list taxonomy=attachment_category mla_item_parameter=current_attachment_category mla_output=dropdown option_all_text=All option_all_value=all hierarchical=true show_count=true pad_counts=true use_filters=true mla_option_value="{+slug+}" minimum=1]</div>

    Results
    [mla_gallery add_filters_to=any columns=3 size=large link=file post_parent=all option_all_value=all tax_operator=AND mla_style="experiment-default-basis-top" mla_markup="experiment-default-basis"]

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your update with all the progress you have made.

    You wrote “There are always three levels. In most of the cases level 1 or 2 does not work“. The answer is hinted at in this excerpt from the “Simple Taxonomy Parameters” section of the Documentation:

    Note that the default tax_include_children value is true, matching the default WordPress setting. If your tax_operator is “AND”, you will almost certainly want to change this setting.

    The tax_include_children=true parameter adds all three term values to the database query. The tax_operator=AND parameter then requires the items to be assigned to ALL THREE terms for inclusion in the results. If you assign the item(s) to just the lowest level term, they will be included in the pad_counts=true result but not the actual gallery display.

    Regarding the [mla_term_list] counts, note that they include all post_mime_type values, so the count will be higher than the gallery display if non-image items are assigned to the term(s).

    I hope that helps to explain the results you are getting.

    Good Morning, David. Thnkas for explaining.

    When I enter a criteria for attachment_categories, attachment_tags is set to all and the text criteria is empty.

    No Results.

    att.cat [mla_term_list taxonomy=attachment_category mla_item_parameter=current_attachment_category mla_output=dropdown option_all_text=All option_all_value=all hierarchical=true show_count=true pad_counts=true use_filters=true mla_option_value="{+slug+}" minimum=1]

    att.tags [mla_term_list taxonomy=attachment_tag mla_item_parameter=current_tag1 mla_output=dropdown option_all_text=All option_all_value=all show_count=true use_filters=true mla_option_value="{+slug+}" mla_markup=term-list-named term_list_name=tag1 minimum=1]

    text [muie_keyword_search mla_phrase_delimiter=' ' mla_phrase_connector='OR']

    results [mla_gallery add_filters_to=any columns=3 size=large link=file post_parent=all option_all_value=all tax_operator=AND mla_style="experiment-default-basis-top" mla_markup="experiment-default-basis"]

    MY apologies. With Respect to my comment before. 3 categories in hierarchy. All of Them are assigned to the Image. I select the Top Category. No results. I select the 2nd Category. No results. I select the 3rd Category. Images is displayed as a result.

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your update and for the complete text of your shortcodes; very helpful.

    I have copied your shortcodes to my system and run some tests. I realize that my earlier explanation of the tax_include_children=true and tax_operator=AND combination was wrong; let me try again.

    The tax_include_children=true parameter adds the selected term value and all of its children term values to the database query. The tax_operator=AND parameter then requires the items to be assigned to the selected term and all of its children terms for inclusion in the results.

    So, if you select a Top Category that has more than one 2nd Category, the item would have to be assigned to all of the 2nd Category values (and 3rd Category values) to be included in the results. It is not sufficient for the item to be assigned to one term at each level.

    The best solution I can suggest is to set pad_counts=false and add tax_include_children=false to your [mla_gallery] shortcode. In my testing, this combination produced reasonable results.

    I realize, that I did not react an your latest comment. Your suggestions are useful for me.

    After that I moved from a hierarchical category structure to a flat category structure. Thats the best solution for me.

    Good Morning David. One minor question to the solution for my scenario wgich is a combination of search fields, a submit button and a presentation of search results on a dedicated page, using “MLA UI Elements Example” plugin.

    Is it possible to call this page with an empty space for results? As for now, all images will be displayed in the beginning according to the initial search fields which does not make sense in my context.

    Thanks and it’s not urgent 🙂

    Plugin Author David Lingren

    (@dglingren)

    It’s good to see you are getting close to a solution.

    The easiest way to start with an empty gallery is to remove the post_parent=all parameter from your [mla_gallery] shortcode. That will limit the display to those items attached to the page; there should not be any.

    As a precaution I have added a new default_empty_gallery parameter to the example plugin. If the above suggestion does not work for you I will upload a new Development Version and you can try that.

    For my solution your suggestion works perfect. David, many thanks for your support.
    Cheers, Ernst Wilhelm

Viewing 13 replies - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.