• Resolved Winework

    (@winework)


    Hello David,

    I hope you can help me with two more difficulties.

    1) I’m now very happy with the way I’ve got my MLA Gallery to display but I would like to give users the option to filter results by attachment_category.

    The simplest way would be for me to have a drop-down into which I can include the att_cat options I want to. When the user selects an att_cat from the drop-down and clicks GO, the gallery displays the product images in that attachment category.

    I’ve read a number of related support threads but cant seem to get any of the suggested solutions to function correctly.

    Here’s the sort of thing I’m trying to do…

    Please select an Attachment Category value:
    
    <form id="attachment_category" method="get" action="">
    	<select name="attachment_category" class="postform">
    		<option selected value="Spirits">Spirits</option>
    		<option value="whiskey">Whiskey</option>
    		<option value="liqueurs">Liqueurs</option>
    		<option value="cognac">Cognac</option>
    	</select>
    	<input type="submit" id="submit" name="submit" value="GO">
    </form>
    
    [mla_gallery attachment_category="{+request:attachment_category+}"]

    You can see the results this achieves here: https://www.winework.com/print-image-library/

    The password is your surname.

    As you can see, it seems to be displaying all images, not the att_cat. Then, when a new category is selected, it seems to be searching through post archives!

    I’m confused again… any clues?

    2) If you take a look at the Product Image Gallery, it seems to be loading really slowly. I’m on a fibre connection and it is taking up to 18 seconds to return a page.

    Can you suggest anything that might be clogging the works?

    Thanks again for any assistance you may be able to provide.

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

    (@dglingren)

    Thanks for your questions and for the link to your test page; very helpful.

    You wrote “it seems to be displaying all images…“; I understand that to mean that when you first visit the page you see the entire library, not just the default “Spirits” collection. This happens because the attachment_category query argument is not set until the form is submitted, so the {+request:attachment_category+} parameter is empty and the default is to display everything. You can change the initial value by using a content template in your shortcode, e.g.:

    
    [mla_gallery attachment_category="{+template:{+request:attachment_category+}|spirits+}"]
    

    to display the “Spirits” category or:

    
    [mla_gallery attachment_category="{+template:{+request:attachment_category+}|a-bad-term+}"]
    

    to start with an empty gallery.

    On my system, when I select a category and click “GO” I get the appropriate gallery display, not the post archives. You might need to change the action parameter of your form to action="." or action="https://www.winework.com/print-image-library/".

    You mentioned searching through earlier topics; thank you for making that effort. The two most recent and useful articles are:

    Limiting search results to attachment tags/”Justifying” gallery grids

    Very new to this, need help

    In those topics you will see how to use the [mla_term_list] shortcode to generate the select tag content and an example plugin that provides several enhancements to the overall operation of the page.

    I hope that gives you the information you need to complete your application.

    • This reply was modified 8 years, 6 months ago by David Lingren.
    Plugin Author David Lingren

    (@dglingren)

    I hope the above suggestions got you the results you needed.

    It has been 11 weeks since the last post in this topic, so I am marking it resolved. Please update it if you have problems or further questions regarding the above suggestions.

    Thread Starter Winework

    (@winework)

    Hello David,

    To begin, thank you again for all the help you’ve been in getting our image gallery functioning the way we wanted. You’ve made a awesome plug-in and the support is top-notch.

    I’m wondering if you could advise me on a change I would like to make to the behind the scenes operation on our site.

    I have been using the att_cat to categorize all our product images by brand, which seems to be more useful than by product-type.
    (eg: att_cat>brand>absolut)

    This works great, but in the image library page, I have to manually add each new brand to the drop-down options list.

    My question is, is there a sneaky piece of code that will automatically populate the drop-down options list with the brand names as I create them in the att_cat?

    Here is the existing code, showing a handful of brands for brevity. The eventual list could be in well over 100 long.

    <form id="attachment_category" action="" method="get"><select class="postform" name="attachment_category">
    <option value="brand">ALL BRANDS</option>
    <option value="35-south">35 South</option>
    <option value="aberlour">Aberlour</option>
    <option value="absolut">Absolut</option>
    </select><input id="submit" name="submit" type="submit" value="GO" />
    
    </form>[mla_gallery attachment_category={+template:{+request:attachment_category+}|steve-bird+} posts_per_page="50" mla_output="paginate_links,prev_next"]
    
    [mla_gallery attachment_category="{+template:{+request:attachment_category+}|steve-bird+}" size="medium" posts_per_page="50" orderby="title"]
    
    [mla_gallery attachment_category={+template:{+request:attachment_category+}|steve-bird+} posts_per_page="50" mla_output="paginate_links,prev_next"]

    Any advice you can offer would be greatly appreciated.

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your positive comments and for your question.

    MLA provides a shortcode that can generate a dropdown containing the terms assigned to your items. You can find a solution much like the one you posted above in the “MLA Term List Examples” section of the Settings/Media Library Assistant Documentation tab.

    Have a look at the [mla_term_list] shortcode and examples in the Documentation and see if you use it in your application. If you have problems or further questions, post an update here and I can give you more specific help. Thanks for your continuing interest in the plugin.

    Thread Starter Winework

    (@winework)

    Hello David,

    Thanks for your guidance. I have managed to get things partially working, but I just cant seem to get the pagination to function correctly.

    Can you please take a look and suggest where I have got it wrong?

    My code is…

    <form id="mla-text-form" class="row" action="." method="post"><strong>Select a Brand to View...</strong>
    
    [mla_term_list taxonomy=attachment_category mla_output=dropdown mla_option_value="{+slug+}" show_count=true pad_counts=false ]
    
    <input id="text-form-submit" name="text_form_submit" type="submit" value="GO" />
    
    </form>
    <h3>Search Results</h3>
    [mla_gallery]
    attachment_category="{+template:({+request:tax_input.attachment_category+}|ruinart)+}" posts_per_page=10 mla_output="paginate_links, prev_next"
    mla_link_href='{+new_url+}?mla_paginate_current={+new_page+}&tax_input[attachment_category]="{+query:attachment_category,text+}"'
    [/mla_gallery]
    
    [mla_gallery attachment_category="{+template:({+request:tax_input.attachment_category+}|ruinart)+}" size="medium" posts_per_page=10 orderby="title"]

    You can see this in operation on the site here: https://www.winework.com/draft-product-image-gallery/

    Your Password is: DavidLingren

    Issues
    1) If for example, you select the brand ‘BABICH’ (22 images), you’ll see the first 10 images. But if you click on the pagination links, the remaining images are not displayed.

    2) I would also like the pagination links to show at the bottom of the results.

    3) Is it possible to limit the drop down display to show only the brands? If not, I’ll just delete the other att cats and leave only the brands.

    Looking forward to hearing from you.

    Best regards,

    Colin

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your update and for posting the complete source text of your form and shortcodes; very helpful. Thanks as well for posting the link to your site and giving me a temporary password to view it.

    I copied your form and shortcodes to my own system and they work there without any problems. When I visited your site and looked at the pagination links they have a small error that accounts for your symptoms. Here is one example:

    
    https://www.winework.com/draft-product-image-gallery/?amp;tax_input%5Battachment_category%5D=%22murray-mcdavid%22&mla_paginate_current=2
    

    You can see some extra characters, amp; just after the question mark separating the page address from the query arguments. This might be a result of using the WordPress editor’s “Visual” tab instead of the “Text” tab to edit the page content.

    In any case, the mla_paginate_current portion of the parameter is not necessary; MLA will add it to the pagination URLs automatically. Try changing the shortcode to:

    
    [mla_gallery]
    attachment_category="{+template:({+request:tax_input.attachment_category+}|ruinart)+}" posts_per_page=10 mla_output="paginate_links, prev_next"
    mla_link_href='{+new_url+}?tax_input[attachment_category]="{+query:attachment_category,text+}"'
    [/mla_gallery]
    

    I believe that eliminates the amp; problem.

    You can show the pagination links at the bottom of the results by simply adding a second copy of the pagination shortcode below the gallery display shortcode.

    You can limit the dropdown list to your brands by adding a child_of or include_tree parameter to your [mla_term_list] shortcode. More information is in the “Term List Data Selection Parameters (Hierarchical Output)” section of the Settings/Media Library Assistant Documentation tab. These parameters take a term_id value, which you can find my going to the Media/Att. Categories admin submenu and hovering over the term Name or Edit rollover action. Look for the number after tag_ID in the edit URL.

    If you have any problems or further questions regarding the above suggestions, post an update and I can give you additional help.

    • This reply was modified 8 years ago by David Lingren.
    • This reply was modified 8 years ago by bdbrown.
    Thread Starter Winework

    (@winework)

    Hi Dave,

    Thanks for all your effort in testing and explaining to me.

    With your guidance, I got it working!

    Once again, awesome plugin, top support.

    Cheers,

    Colin

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Filtering Gallery Display’ is closed to new replies.