• Resolved ernstwg

    (@ernstwg)


    I am using mla to provide access to a pool of images. Basically users have a field for entering freely defined selection criteria and an ok button. Each image has a text. If the criteria matches the description the image will be displayed.

    Can I enter something like
    A BUT NOT B
    or
    A Or B

    eg
    Israel AND NOT Street
    or
    Carmel market OR Yehuda market

    Cheers, Ernst Wilhelm

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

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

    (@dglingren)

    Thanks for your questions and examples. The MLA Keyword Search and Terms Search features are powerful but the documentation is terse.

    I do suggest you start by reading through the “Entering words and phrases” and “Excluding phrases” portions of the “Terms Search – filtering on taxonomy term names” section in the Settings/Media Library Assistant Documentation tab. Most of the material there applies to the Keyword Search features as well as the Terms Search feature.

    The “NOT” operation is covered in the “Excluding phrases” documentation. For the Keywords Search feature you can also prefix a single work with a dash/minus character, e.g. “A -B” in your first example.

    The AND/OR capability is a bit limited but still useful. You can use the mla_search_connector parameter to specify either one to connect the search phrases, but it will apply to all of the phrases entered.

    You can allow the user to control the connector and other features by adding input fields to your search form. Here is an earlier topic with an example of that solution:

    Add searc box to Gallery

    You might also be interested in this earlier topic and the other topics it links to:

    Shortcode Display Help

    You will see in that topic some references and examples using an MLA example plugin, “MLA UI Elements Example”, that provides enhancements like “sticky” input fields that persist when the page is refreshed.

    I hope that gets you started on a search feature that works for your application. I am marking this topic resolved, but please update it if you have problems or further questions regarding the above suggestions and the earlier topics. Thanks for your continued interest in the plugin.

    Thread Starter ernstwg

    (@ernstwg)

    Good Morning. Many thanks for your reply. Some information was quite useful. Some other don’t fit to my ideas perfectly. Can I draw two distinguished search fields (freetext) and connect them for one query to build the mla gallery.

    [mla_gallery s=”{+template:({+request:search-string+}|a-bad-term)+}”]

    If this is the default I am looking for something like

    [mla_gallery s=”{+template:({+request:search-string1+}|a-bad-term)+}” CONNECT s=”{+template:({+request:search-string2+}|a-bad-term)+}”]

    or

    [mla_gallery s=”PHRASE1″ CONNECT s=”PHRASE2″]

    Additionally: for the time being I’ve using MLA Gallery mainly as a combination 2 elements, a button and a search field (with a predefined value). Can I include this predefined value for the search field into the button, that I have only one element?

    Cheers

    • This reply was modified 5 years, 3 months ago by ernstwg.

    Hi with David’s help and a bit of googling I had to use the tax_query to pass the same value (current_id) to both the category and tag.

    [mla_gallery]
    post_mime_type=image/jpeg
    tax_query=”array (
    ‘relation’ => ‘OR’,
    array ( ‘taxonomy’ => ‘attachment_category’,
    ‘field’ => ‘id’,
    ‘terms’ => array( {+request:current_id+} ),
    ‘include_children’ => false,
    ),
    array ( ‘taxonomy’ => ‘attachment_tag’,
    ‘field’ => ‘id’,
    ‘terms’ => array( {+request:current_id+} ),
    ),
    )”
    orderby=date
    order=ASC
    size=icon
    link=file
    mla_alt_shortcode=justified_image_grid
    [/mla_gallery]

    The result is here https://cuckoofair.co.uk/new-gallery

    Thread Starter ernstwg

    (@ernstwg)

    Hey there. Many thanks for your great example. Some months ago I switched my way of putting information to my images (stored locally in Lightroom LR), publishing the images from LR onto my website. So I don’t use att.catgegories and att.tags anymore. Every searchable information is within the field description, organised during the process of publishing. If you want to look at it, here you are [New tab].

    1. Can I connect 2 search_strings for building a mla_gallery.
    2. Can I use only a buttons (1 UI element) instead of one or two search-fields and a button, which means 2 or 3 UI elements (UI = User interface).

    Am I clear?

    Plugin Author David Lingren

    (@dglingren)

    Thanks, @cuckoofairweb, for adding to this topic with your solution!

    Thanks, @ernstwg, for the additional details and the link to your page; very helpful. I hope I understand your points.

    You wrote “Can I connect 2 search_strings“? Here is a possible solution that works on my test site:

    <form id="mla-search-form10" action="." method="post">
    String 1: <input name="search-string1" id="mla-search-box10-1" type="text" size="15" value="">
    <br />
    String 2: <input name="search-string2" id="mla-search-box10-2" type="text" size="15" value="">
    <br />
    <select name="search-connector">
    <option value="AND">both</option>
    <option value="OR">either</option>
    </select>
    <br />
    <input name="submit10" id="submit10" type="submit" value="Suchen">
    </form>
    
    [mla_gallery]
    s=' "{+template:({+request:search-string1+}|a-bad-term)+}" "{+template:({+request:search-string2+}|a-bad-term)+}" '
    mla_search_connector={+template:({+request:search-connector+}|OR)+}
    [/mla_gallery]
    

    You can see that I combined both strings into the single s= field, surrounded by quotes so the match must include all words in each phrase. Your CONNECT term is handled by the dropdown control and the search-connector parameter.

    You wrote “Can I use only a buttons“? You can add hidden fields to your form to accomplish this, I think. For example:

    <form id="mla-search-form11" action="." method="post">
    <input name="search-string1" id="mla-search-box11-1" type="hidden" value="BMW">
    <br />
    <input name="search-string2" id="mla-search-box11-2" type="hidden" value="wallpaper">
    <br />
    <select name="search-connector">
    <option value="AND">both</option>
    <option value="OR">either</option>
    </select>
    <br />
    <input name="submit11" id="submit11" type="submit" value="Suchen">
    </form>
    

    Change the “value” attributes to suit your application.

    I hope the above suggestions are useful. Please post an update if you have problems or further questions about them. Thanks.

    Thread Starter ernstwg

    (@ernstwg)

    David. Your help is appreciated. What I wanted to achieve, works perfectly right now. Many thanks, Ernst Wilhelm [RESOLVED]

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Logical operators’ is closed to new replies.