• Resolved ernstwg

    (@ernstwg)


    Hi David. Long time no hear and I hope you and all your beloves ones are well and alive.

    Some years ago I was much more familiar with searching facilities within MLA. Today thats no longer the case and perhaps you can help me.

    I want to build a search form which covers images for a certain parent category (the sample plugin smart media categories is already in place). I guess I would like this search criteria to be visible but without giving the user the option to change the value. So this would be the first search field. A second search field is a free entry search field, for which I would like to give the user the descison wether ist should be an AND or an OR or AS connector.

    AS means searching the phrase entered.

    1st field A is a fixed category, connected with AND to 2nd field B. The 3rd field defines AND / OR / AS connector for more words in 2nd field B.

    I would really appreciated it, if you can give me some hints.

    Thanks, Ernst Wilhelm

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

    (@dglingren)

    Good to hear from you again. Thanks for your patience while I was traveling.

    You wrote “a search form which covers images for a certain parent category visible but without giving the user the option to change the value“. You can hard-code the category name/slug in the shortcode parameters and hard-code the category title in the content of the post/page containing the search form. Do you need anything more complex than that?

    You wrote “A second search field is a free entry search field“. MLA provides two different search features. The “Keyword(s) Search” feature searches in WordPress standard fields such as Title, Caption and Description. The “Taxonomy term keyword(s) search” feature searches the Name field of taxonomy terms. You can find more information of either feature in the Settings/Media Library Assistant Documentation tab. Which of these two features do you want to use?

    You wrote “I would like to give the user the descison wether ist should be an AND or an OR or AS connector. AS means searching the phrase entered.” I believe the “AS” option is the same as addingsentence=true as a shortcode parameter:

    sentence – Add sentence=true to require that all of the words entered must match in sequence. This is equivalent to putting quotes around all of the words in your search.

    Is that what you want?

    If you answer the above questions I can work on a solution for your application.

    Thread Starter ernstwg

    (@ernstwg)

    Hi David. Many thanks for your excellent and reliable work.

    I will be off during the christmas season. probably I can have a look at my e-mails and can read documentation.

    My imagination of getting the content of html fields into the mla gallery shortcode is let’s say a bit foggy. A further step on my side would be probably some php coding do build this shortcode to adapt a fundamental solution to a variety of requirements in the field. Not to say that I know them all right now.

    I appreciate a shortcode sample which covers, a hardcoded category name/slug, a search field based on “Keyword(s) Search”, a connector field (understood your hints).

    I guess categories and tags (available via smart media categories) will be covered when I add ‘terms’ to mla_search_fields.

    [question 1 which comes up right now] Just to see whats possible Is it possible to add a hidden search criteria as a MUST to a “Keyword’s search” something like

    s="{+template:('MUST' AND {+request:search-string+}|a_bad_term)+}" or

    s="{+template:({+request:search-string_1+}|a_bad_term AND {+request:search-string_2+}|a_bad_term)+}"

      Plugin Author David Lingren

      (@dglingren)

      Thanks for clarifying your requirements.

      You wrote “I appreciate a shortcode sample which covers, a hardcoded category name/slug, a search field based on “Keyword(s) Search”, a connector field (understood your hints).” I have developed an example HTML form and [mla_gallery] shortcode that meets your requirements. The example does not require any PHP coding and can probably be adapted to other search requirements.

      You wrote “I guess categories and tags (available via smart media categories) will be covered when I add ‘terms’ to mla_search_fields.” Yes, that’s correct. You can use the mla_search_fields parameter to specify the fields you want to search. The example below searches all of the available fields; you can remove the fields you do not want to include.

      You wrote “Is it possible to add a hidden search criteria as a MUST to a ‘Keyword’s search’ …” Yes, it is. The Smart Categories example plugin copies the terms assigned to an item’s parent post/page and assigns them to the item itself. In the shortcode you simply add a Simple Taxonomy Parameter to add a taxonomy term filter to the results, e.g., category="abc" in the example below.

      Your application includes two different “connector fields”. In the example below, the AND/OR connector is handled by two HTML radio buttons. You wrote “AS means searching the phrase entered“; this is handled by the sentence shortcode parameter. In the form this is implemented by a checkbox. If you check the box, the sentence parameter overrides the AND/OR connector.

      Here are the example form and shortcode parts for your application:

      <form id="mla-search-form" action="." method="post">
      <label for="mla-search-box">Text:</label>
      <input id="mla-search-box" name="search-string" type="text" size="40"value="" /><br />
      &nbsp;<br />Connector:&nbsp;
      <input id="mla_search_connector" name="search-connector" type="radio" value="AND" checked="checked"/>
      <label for="mla_search_connector_AND">AND</label>
      <input id="mla_search_connector" name="search-connector" type="radio" value="OR" />
      <label for="mla_search_connector_OR">OR</label>
      &nbsp;&nbsp;&nbsp;&nbsp;
      <input id="mla_search_sentence" name="search-sentence" type="checkbox" value="true" />
      <label for="mla_search_sentence">Sentence</label><br />
      &nbsp;<br /><input id="submit" name="submit" type="submit" value="Search" />
      </form>

      [mla_gallery]
      category="abc"
      s="{+template:({+request:search-string+}|a-bad-term)+}"
      mla_search_fields="title,name,excerpt,content,alt-text,file,terms"
      mla_terms_taxonomies="category"
      mla_search_connector="{+template:({+request:search-connector+}|AND)+}"
      sentence="{+template:({+request:search-sentence+}|false)+}"
      mla_nolink_text="Enter a search value above to display gallery."
      [/mla_gallery]

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

    Viewing 3 replies - 1 through 3 (of 3 total)

    The topic ‘Searching’ is closed to new replies.