• Resolved beachman14

    (@beachman14)


    The more I study the documentation, the more impressed I am with everything that this plugin can do.

    I am having trouble getting the s= terms search to work properly. Here is the code I am using for my mla gallery:

    <form id=”mla-search-form” action=”.” method=”post”>
    <input id=”mla-search-box” name=”search-string” type=”text” value=””> <input id=”submit” name=”submit” type=”submit” value=”Search”>
    </form>

    [mla_gallery mla_page_parameter=gallery_pictures post_parent=all attachment_category=Pictures posts_per_page=48 mla_caption=”{+title+}” s=”{+request:search-string+}”]

    The page displays the input form but when I input a value and click the submit button, it just takes me to the home page. I know that the s= funtion works because if I replace “{+request:search-string+}” with an actual value (like “1965”, for example) the gallery displays only the pictures with that value in their title or description. But when I try to use the input form, it just doesn’t seem to work. I have studied the documentation over a period of days and tested s= a variety of ways For example, I have read “Remember to use post_parent=current if you want to restrict your query to items attached to the current post” but that does not seem to make a difference. Might you be able so shed some light on what I am doing wrong?

    Thanks,
    Mark

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

    (@dglingren)

    Thanks for the positive MLA feedback and for your question. Thanks as well for including the source text of your form and shortcode; very helpful.

    I have tested your form and shortcode on my system (adjusting the attachment_category value) and it is working without errors.

    You wrote “when I input a value and click the submit button, it just takes me to the home page.” This is probably not an MLA problem. In some cases, the action=”.” attribute does not return to the current page but goes to the home page instead. You can test this and probably fix the problem by hard coding the path back to the current page in the attribute. For example, if the URL is something like https:mysite.com/my-search-page/ you can code action="/my-search-page/'.

    I also noted that your shortcode displays all the site’s images until a search string is entered. If you want to start with an empty gallery, you can use:

    s="{+template:{+request:search-string+}|empty-gallery-search-string+}"
    

    There’s nothing special about the empty-gallery-search-string part; anything that will not match any title or description will do the job.

    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 interest in the plugin.

    Thread Starter beachman14

    (@beachman14)

    David,
    Thank you for that suggestion about action=”.” That absolutely fixed it. I also thank you for the suggestion about displaying an empty gallery, but in my case, I want to show everything in the gallery until the site visitor enters a value in the search form.

    I am now working on pagination. Thanks to your help I have gotten pagination to work and I have gotten the search form to work, but I cannot get them to work together. This is my code:

    <form id=”mla-search-form” action=”https://newmanation.org/library&#8221; method=”post”>
    <input id=”mla-search-box” name=”search-string” type=”text” value=””> <input id=”submit” name=”submit” type=”submit” value=”Search”>
    </form>
    [mla_gallery mla_page_parameter=gallery_pictures post_parent=all attachment_category=Pictures posts_per_page=12 mla_caption=”{+title+}” s=”{+request:search-string+}”]
    [mla_gallery mla_page_parameter=gallery_pictures post_parent=all attachment_category=Pictures posts_per_page=12 mla_output=”previous_page,first” mla_link_text=’← Previous Gallery Page’ mla_rollover_text=”Previous or first page for this tag”]
    <div style=”float: right”>
    [mla_gallery mla_page_parameter=gallery_pictures post_parent=all attachment_category=Pictures posts_per_page=12 mla_output=”next_page,last” mla_link_text=’Next Gallery Page → ‘ mla_rollover_text=”Next or last page for this tag”]
    </div>

    With the pagination shortcodes added, when I enter a value and click the Search button, the gallery does not change and the search form dissapears. My page has four mla galleries on it that are differentiated by different mla_page_parameter values. I don’t know if that makes a difference or not. I was hoping to have a search form for each mla gallery. Can that work? Again, I have attempted to solve the issue by researching the documentation before reaching out again. Sorry to be such a pest!

    Thanks,
    Mark

    Thread Starter beachman14

    (@beachman14)

    David,
    Upon further testing, the issue does appear to be related to having multiple galleries on a single page. I used the exact same code on a page with a single gallery and it worked great: search and pagination together. I can separate my galleries onto separate pages if I need to, but I was hoping to have four galleries on the same page. Your thoughts are greatly appreciated.
    Thanks again,
    Mark

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your updates with the additional information and your progress.

    You wrote “With the pagination shortcodes added, when I enter a value and click the Search button, the gallery does not change and the search form disappears.” I assume you mean that the form remains but the value you enter in the text box disappears; is that right? This should happen even if there’s only one gallery on the page.

    You wrote “I was hoping to have a search form for each mla gallery.” I assume that means you want four separate forms on the page, each linked to one set of gallery and pagination controls; is that right?

    Regarding the disappearing search text, this happens because the form values are not retained when the page is refreshed. I developed the “MLA UI Elements Example” plugin to solve this and other problems.

    I am working on a solution for multiple forms and galleries on one page. I will post an update when I have progress to report. Your answers to the above questions will be helpful. Thanks for your patience.

    Thread Starter beachman14

    (@beachman14)

    Thank you again for your superior level of support.

    When I wrote “With the pagination shortcodes added, when I enter a value and click the Search button, the gallery does not change and the search form disappears,” what I meant to say is that the entire form, including the input box and the button disappears. I am using the Astra theme if that matters.

    On your other question, you are correct in that I was hoping to have four separate forms on the page, each linked to one set of gallery and pagination controls.

    At present, I have changed my site so as to place each of the four galleries on their own page, so I am ok for now. The issue is not pressing. Thanks again for a great plugin and superior support.

    Plugin Author David Lingren

    (@dglingren)

    Thanks for the kind words and for your further information.

    You wrote “… the entire form, including the input box and the button disappears.” That is very odd. I would have to see this problem in action to investigate further. I hope it will be resolved with the solution proposed below.

    Thanks as well for your patience while I worked out some improvements required to support your application. I found and fixed a few minor bugs in the existing MLA code and added a new muie_keyword_parameter to the “MLA UI Elements Example” plugin’s [muie_keyword_search] shortcode. The example plugin includes a Settings/MLA UI Elements page with a Documentation tab that explains everything.

    Here is an example you can adapt. It contains two “search form and gallery” sets which will retain their settings across page refreshes.

    <h3>MUIE multiple forms and galleries</h3>
    <form id="mla-search-form-1" action="." method="post">[muie_keyword_search muie_keyword_parameter=form-1] <input id="submit" name="submit" type="submit" value="Search" />
    [mla_gallery]
    mla_page_parameter=gallery_pictures
    muie_keyword_parameter=form-1
    post_parent=all attachment_category=abc add_filters_to=any posts_per_page=1
    mla_caption="{+title+}"
    [/mla_gallery]    
    <p>&nbsp;</p>
    <div style="float: left;">
    [mla_gallery]
    mla_page_parameter=gallery_pictures
    muie_keyword_parameter=form-1
    post_parent=all attachment_category=abc add_filters_to=any posts_per_page=1
    mla_output="previous_page,first"
    mla_link_text='← Previous Gallery Page' mla_rollover_text="Previous or first page for this tag"
    [/mla_gallery]</div>
    <div style="float: right;">
    [mla_gallery]
    mla_page_parameter=gallery_pictures
    muie_keyword_parameter=form-1
    post_parent=all attachment_category=abc add_filters_to=any posts_per_page=1
    mla_output="next_page,last"
    mla_link_text='Next Gallery Page → ' mla_rollover_text="Next or last page for this tag"
    [/mla_gallery]</div>
    <h4>&nbsp;<br />Second form and gallery</h4>
    <p>[muie_keyword_search muie_keyword_parameter=form-2] <input id="submit" name="submit" type="submit" value="Search" /></p>
    </form>
    <p>[mla_gallery] mla_page_parameter=gallery_pictures_2 muie_keyword_parameter=form-2 post_parent=all attachment_category=abc add_filters_to=any posts_per_page=1 mla_caption="{+title+}" muie_debug=log [/mla_gallery]</p>
    <div style="float: left;">[mla_gallery] mla_page_parameter=gallery_pictures_2 muie_keyword_parameter=form-2 post_parent=all attachment_category=abc add_filters_to=any posts_per_page=1 mla_output="previous_page,first" mla_link_text='← Previous Gallery Page' mla_rollover_text="Previous or first page for this tag" muie_debug=log [/mla_gallery]</div>
    <div style="float: right;">[mla_gallery] mla_page_parameter=gallery_pictures_2 muie_keyword_parameter=form-2 post_parent=all attachment_category=abc add_filters_to=any posts_per_page=1 mla_output="next_page,last" mla_link_text='Next Gallery Page → ' mla_rollover_text="Next or last page for this tag" muie_debug=log [/mla_gallery]</div>
    

    There is one HTML form spanning both of the [muie_keyword_search] shortcodes and their Submit buttons. This ensures that both of the search values are “sticky” regardless of which Submit button is clicked. Each [muie_keyword_search] shortcode has a unique muie_keyword_parameter value, and the same value is entered in all three of the [mla_gallery] shortcodes for the gallery and navigation sontrols. You can change the attachment_category and posts_per_page parameters to suit your application.

    I have uploaded a new MLA Development Version dated 20220424 that includes an updated “MLA UI Elements Example” plugin. You can find step-by-step instructions for using the Development Version in this earlier topic:

    PHP Warning on media upload with Polylang

    Once the Development Version is installed you must install and activate the example plugin. Navigate to the Settings/Media library Assistant Documentation tab and click the “Example Plugins” button. Type “UI” in the text box and click “Search Plugins” to filter the table.

    You are looking for the “MLA UI Elements Example” plugin. Make sure it is the latest version, 2.02. Find that plugin and hover over the title in the left-most column. Click the “Install” rollover action, then go to the WordPress Plugins/Installed Plugins submenu and activate the example plugin as you would any other plugin.

    Once the Development Version and new example plugin are installed and active you can compose a multi-gallery page along the lines of the example above.

    This updated example plugin will be part of my next MLA version, but in the interim it would be great if you could install the Development Version and the example plugin and let me know if it works for you. Thanks for inspiring this MLA improvement.

    Thread Starter beachman14

    (@beachman14)

    David,

    I apologize for my late response, I have been unable to get back to this until just now. Thank you for all of your work on this. I have the new version of the plugin installed and I will begin working with the example code you sent.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Trouble with s=’ is closed to new replies.