• Resolved hahalj

    (@hahalj)


    Hi!
    I’m using this code to provide search capabilities in my media library and provide a Photonic gallery as output from the result:

    <form id="mla-search-form" action="." method="post">
    <input id="mla-search-box" name="search-string" type="text" value="">&nbsp;<input id="submit" name="submit" type="submit" value="Search">
    </form>
    [mla_gallery size=medium mla_alt_shortcode="gallery type=default style=masonry main_size=1920" s="{+template:({+request:search-string+}|a-bad-term)+}" mla_nolink_text="Enter a search value above to display images." mla_output="paginate_links,prev_next" mla_link_href="{+page_url+}?search-string={+request:search-string+}"]

    There are two issues I haven’t found a way to solve:

    1. I can only enter one keyword to get a successful search, how should I change the code to get a search with combination of keywords, either “key1 OR key2”, or “key1 AND key2” ?

    2. How can I restrict the search to only include specific parts of media file information, like e.g. Title, Filename but nothing else?

    Thanks.

    • This topic was modified 3 years, 11 months ago by hahalj.

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

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter hahalj

    (@hahalj)

    I found the answer to my second question, if I add
    mla_search_fields="title,file"
    to my shortcode it only match towards these fields.

    Still for my first question I haven’t figured out how to do it. In the search input I’d like to write for example “sunset,winter” and then get all photos matching either both or any of those. Can’t figure out how to do it, or if it’s even possible.

    • This reply was modified 3 years, 11 months ago by hahalj.
    • This reply was modified 3 years, 11 months ago by hahalj.
    Thread Starter hahalj

    (@hahalj)

    Something’s not right on my side, the documentation says:

    “The user can enter one or more words to search for in the Title or Description of Media Library items, then click “Search” to display a gallery of matching images:”

    When I use an exact copy-and-paste from the documentation sample code:

    <form id="mla-search-form" action="." method="post">
    <input id="mla-search-box" name="search-string" type="text" value="" />&nbsp;<input id="submit" name="submit" type="submit" value="Search" />
    </form>
     
    [mla_gallery s="{+template:({+request:search-string+}|a-bad-term)+}" posts_per_page=12 mla_output="paginate_links,prev_next" mla_link_href="{+page_url+}?search-string={+request:search-string+}"]
     
    [mla_gallery s="{+template:({+request:search-string+}|a-bad-term)+}" mla_nolink_text="Enter a search value above to display gallery." posts_per_page=12]

    I still can only use a single word search. Two words always give me empty result, even though the words are present in both photo titles and/or file names.

    What could possibly be wrong?

    Thread Starter hahalj

    (@hahalj)

    Alright, I found the solution. By adding this to my shortcode it all works as I want to:
    mla_search_connector="OR"

    Thanks for an excellent and extremely versatile plugin!

    Plugin Author David Lingren

    (@dglingren)

    Thanks for the positive feedback on MLA and for your questions. Thanks as well for putting in the work to find your own answers while I was traveling and away from my computers.

    I am leaving this topic resolved, but please update it if you have any other problems or questions regarding the keyword search features of the [mla_gallery] shortcode. Thanks for your interest in the plugin.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Searching with multiple keywords’ is closed to new replies.