Support » Plugin: Media Library Assistant » Drop down not sticking

  • Resolved ageingdj

    (@ageingdj)


    Hi there,
    I have this code that works – almost!
    but everytime the select button is pressed the drop down reverts to the first choice.
    The result is that only the first page (up to 30) of photos are shown and when page 2 is chosen you get a blank screen.
    This feels like it should be a simple thing to put right but I’m usually wrong.
    Many thanks
    Paul Miller
    PS where in the code is the image size please – I want medium not small.

    <form id=”mla-text-form” action=”.” method=”post” class=”row”>
    Categories Dropdown
    [mla_term_list taxonomy=category mla_output=dropdown mla_option_value=”{+slug+}” show_count=true pad_counts=false]

    <form id="mla-text-form" action="." method="post" class="row">
    <strong>Categories Dropdown</strong>
    [mla_term_list taxonomy=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="Search">
    </form>
    
    <h3>Gallery</h3>
    [mla_gallery]
    s="{+request:mla-search-string+}"
    mla_search_fields="title,terms" mla_terms_taxonomies=attachment_tag
    category="{+template:({+request:tax_input.category+}|no-term-selected)+}" posts_per_page=30 mla_output="paginate_links,prev_next"
    mla_link_href='{+new_url+}?mla_paginate_current={+new_page+}&tax_input[category]="{+query:category,text+}"'
    [/mla_gallery]
    
    [mla_gallery]
    s="{+request:mla-search-string+}"
    mla_search_fields="title,terms" mla_terms_taxonomies=tag
    category="{+template:({+request:tax_input.category+}|no-term-selected)+}" posts_per_page=30 mla_caption="{+title+} : {+description+}" mla_nolink_text="<br>Select a term to display the gallery.<br>"
    [/mla_gallery]

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

Viewing 15 replies - 1 through 15 (of 15 total)
  • Apologies, I started by code in the wroung place:

    <form id="mla-text-form" action="." method="post" class="row">
    <strong>Categories Dropdown</strong>
    [mla_term_list taxonomy=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="Search">
    </form>
    
    <h3>Gallery</h3>
    [mla_gallery]
    s="{+request:mla-search-string+}"
    mla_search_fields="title,terms" mla_terms_taxonomies=attachment_tag
    category="{+template:({+request:tax_input.category+}|no-term-selected)+}" posts_per_page=30 mla_output="paginate_links,prev_next"
    mla_link_href='{+new_url+}?mla_paginate_current={+new_page+}&tax_input[category]="{+query:category,text+}"'
    [/mla_gallery]
    
    [mla_gallery]
    s="{+request:mla-search-string+}"
    mla_search_fields="title,terms" mla_terms_taxonomies=tag
    category="{+template:({+request:tax_input.category+}|no-term-selected)+}" posts_per_page=30 mla_caption="{+title+} : {+description+}" mla_nolink_text="<br>Select a term to display the gallery.<br>"
    [/mla_gallery]
    Plugin Author David Lingren

    (@dglingren)

    Good to hear form you again, and thanks for posting the complete source text of the shortcodes on your page; very helpful.

    You wrote “everytime the select button is pressed the drop down reverts to the first choice.” That’s true; pressing the “Search” button refreshes the page, which sets the dropdown back to its initial value. There’s nothing in the core MLA plugin to fix this, but an example plugin has been developed for several earlier topics that will add this feature among many others.

    I copied your shortcode text to my system and updated it to use the example plugin. During my testing I found and fixed a few defects in the example plugin, and I have uploaded a new MLA Development Version dated 20191211 that includes the fixes. 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 (or update) and activate (or verify) 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. Find that plugin and hover over the title in the left-most column. Click the “Install” (or “Update”) rollover action, then go to the WordPress Plugins/Installed Plugins submenu and verify or activate the example plugin as you would any other plugin. Make sure you have the latest version, 1.12, installed.

    Once the Development Version and updated example plugin are installed and active you can go back to your application page and modify the shortcodes to use the new feature. Here is the updated text that is working on my test system:

    <form id="mla-text-form" action="." method="post" class="row">
    <strong>Categories Dropdown</strong>
    [mla_term_list use_filters=true taxonomy=category mla_output=dropdown mla_option_value="{+slug+}" show_count=true pad_counts=false  option_all_text=All]
    
    <input id="text-form-submit" name="text_form_submit" type="submit" value="Search">
    </form>
    
    <h3>Gallery</h3>
    [mla_gallery]
    s="{+request:mla-search-string+}"
    mla_search_fields="title,terms" mla_terms_taxonomies=attachment_tag
    category="{+template:({+request:tax_input.category+}|no-term-selected)+}" posts_per_page=30 mla_output="paginate_links,prev_next"
    mla_link_href='{+new_url+}?mla_paginate_current={+new_page+}&tax_input[category]="{+query:category,text+}"'
    [/mla_gallery]
    
    [mla_gallery]
    s="{+request:mla-search-string+}"
    mla_search_fields="title,terms" mla_terms_taxonomies=tag
    category="{+template:({+request:tax_input.category+}|no-term-selected)+}" posts_per_page=30 size=medium mla_caption="{+title+} : {+description+}" mla_nolink_text="<br>Select a term to display the gallery.<br>"
    [/mla_gallery]
    

    I have made two additions to the opening [mla_term_list] shortcode. First, I added use_filters=true to make the dropdown “sticky”, i.e., retain the selected value when the page is refreshed. Second, I added option_all_text=All to the end of the shortcode to provide a default value for the control when the page is first loaded. That’s optional, but helpful.

    You also asked “where in the code is the image size please“. I have added a size=medium parameter to the last shortcode (that displays the gallery). There’s no need to add it to the pagination controls shortcode above that.

    I hope the changes and the updated plugin will give you the results you need. I will leave this topic unresolved in case you have problems or further questions regarding the above suggestions.

    David,

    This is not my post. Someone piggybacked onto my previous request.

    Hi Nickchia,
    My abject apologies if I piggybacked any post, I had no intention to and will try not to again, I just identified your script as solving my problem.

    David,
    As always, many thanks for such a detailed answer but I won’t get a chance to look at it properly until Monday.
    Thanks
    Paul

    Hi Paul,

    No problem. I was receiving emails and I did not want to confuse David between our issues.

    Good luck. I hope everything works for you.

    Nick

    Hi David,
    Your plugin is pretty wonderful but I’m afraid that I just can’t get the code to stick – my dyslexic brain refuses to process it!
    Your code below works a treat but a couple of tweaks please:
    1: The date on the caption is showing as 2018-10-13 18:37:4 How do I change it to dd/mm/yy ?
    2: How do I add the Post title in the caption? (I’ve added a column to the Media Library called “Used in” to the library if it helps)
    3: Group the resulting images by either Post Title or Post Date (latest first).
    4: Have the same caption on the lightbox please

    Lastly
    I want to do the same to show “Images used in Posts grouped by [media library] Category”
    Can I copy the original code and make some simple edits .
    Many thanks for all your help.

    Your code:
    <form id="mla-text-form" action="." method="post" class="row"> <strong>Categories Dropdown</strong> [mla_term_list use_filters=true taxonomy=category mla_output=dropdown mla_option_value="{+slug+}" show_count=true pad_counts=false option_all_text=All] <input id="text-form-submit" name="text_form_submit" type="submit" value="Search"> </form> <h3>Gallery</h3> [mla_gallery] s="{+request:mla-search-string+}" mla_search_fields="title,terms" mla_terms_taxonomies=attachment_tag category="{+template:({+request:tax_input.category+}|no-term-selected)+}" posts_per_page=30 mla_output="paginate_links,prev_next" mla_link_href='{+new_url+}?mla_paginate_current={+new_page+}&tax_input[category]="{+query:category,text+}"' [/mla_gallery] [mla_gallery] s="{+request:mla-search-string+}" mla_search_fields="title,terms" mla_terms_taxonomies=tag category="{+template:({+request:tax_input.category+}|no-term-selected)+}" posts_per_page=30 size=large mla_caption="{+title+} : {+date+} : {+description+}" mla_nolink_text="<br>Select a term to display the gallery.<br>" [/mla_gallery]

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your persistence; I know these shortcode parameters are powerful, but complex. Regarding your four items:

    1. You can use the ,date(f,m) format modifier (as described in the “Field-level option/format values” section of the Documentation tab) to change the date display. For your application, try something like {+date,date('d/m/Y')+} to get the date portion of the value.

    2. When you write “Post title“, do you mean the name of the page in which the gallery display appears, i.e., the current page? If so, you can use {+page_title+} as described in the “Gallery-specific Substitution Parameters” section of the Documentation tab. If instead you mean the Title of the items’ parent, try {+parent_title+}.

    3. Ordering the gallery items is performed by the “Order, Orderby” shortcode parameters. You are limited to the list of choices given in that section of the Documentation. To get something like descending post date order you can try orderby=parent order=DESC.

    4. The lightbox display format is completely controlled by the theme or plugin code that composes the lightbox and I regret that there is no way for MLA to pass information on to that code to affect the display. You may be able to find a solution in the documentation for whatever theme/plugin function you are using for the lightbox display.

    Lastly you asked about “Images used in Posts grouped by [media library] Category”. Where do you want that text to appear? If it is intended as a heading for the gallery display you could define a custom markup template, add the heading to the “Open” section of the template and use the {+request:tax_input.category+} value for the selected term.

    I hope I have understood your questions. Please post an update if you have problems or further questions regarding the above suggestions.

    Hi David,
    Thanks again for your help.
    Adding orderby="ID, DESC"seems to work somehow.
    Changing the date to {+date,date('d/m/Y')+}works perfectly.
    But
    I just can’t work out what the title of any posts the photo is used in is, if the photo was used somewhere, if not return “Unused” (or something similar).

    I’ll try {+request:tax_input.category+} probably Wednesday.

    Thanks again
    Paul

    Plugin Author David Lingren

    (@dglingren)

    Good to see you’re making progress.

    The orderby="ID, DESC" parameter will order the gallery by the ID number assigned to each item as it’s added to the Media Library, so the most recently added item will appear first, etc.

    For your “where-used” information you can experiment with these “field-level data sources” (from the Documentation tab):

    • reference_issues – summary of all reference and parent status “issues”, e.g., orphan, bad parent, invalid parent, unattached
    • featured_in – the title, post/page type and id number of each post/page for which this item is the “featured image”
    • featured_in_title – the title of each post/page for which this item is the “featured image”
    • inserted_in – the title, post/page type and id number of each post/page where this item is inserted in the post/page content
    • inserted_in_title – the title of each post/page where this item is inserted in the post/page content
    • gallery_in – the title, post/page type and id number of each post/page where this item appears in a [gallery] shortcode
    • gallery_in_title – the title of each post/page where this item appears in a [gallery] shortcode
    • mla_gallery_in – the title, post/page type and id number of each post/page where this item appears in an [mla_gallery] shortcode
    • mla_gallery_in_title – the title of each post/page where this item appears in an [mla_gallery] shortcode

    Hi David,
    I’ve just had a quick look at these “field-level data sources” but can’t get anything other that than the image name. I would have thought “featured_in_title” would be the one but no luck.
    I’m using it like this: mla_caption="{+title+} : {+date,date('d/m/Y')+} : {+featured_in_title+}" is that right (there are no examples on your plugin page)?
    Sorry to be such a pain.
    Paul

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your update and for trying out the {+featured_in_title+} data source. Your syntax looks fine and it works on my test system.

    During my testing I re-discovered that you must have the “Featured in” option set to “Enabled” in the “Where-used Reporting” section of the Settings/Media Library Assistant General tab. These features are not enabled by default because they can slow things down with the database word required to populate their results. I regret not adding that to my earlier post.

    Let me know if you need more specific guidance on enabling the option or if it does not resolve your problem.

    ageingdj

    (@ageingdj)

    Hi David,
    This beats me – nothing I try works. {+featured_in_title+} returns blank.
    I’ve tryed most of whats here:
    site_url absolute URL to the site directory, without trailing slash
    base_url absolute URL to the upload directory, without trailing slash
    base_dir absolute (full) path to the upload directory, without trailing slash
    instance starts at ‘1’, incremented for each additional shortcode in the post/page
    selector “mla_term_list-{$instance}”, e.g., mla_term_list-1
    page_ID,
    id the ID value of the post/page in which the list appears
    page_author the post_author value of the post/page in which the list appears
    page_date the post_date value of the post/page in which the list appears
    page_content the post_content value of the post/page in which the list appears
    page_title the post_title value of the post/page in which the list appears
    page_excerpt the post_excerpt value of the post/page in which the list appears
    page_status the post_status value of the post/page in which the list appears
    page_name the post_name value of the post/page in which the list appears
    page_modified the post_modified value of the post/page in which the list appears
    page_guid the post_guid value of the post/page in which the list appears
    page_type the post_type value of the post/page in which the list appears
    page_url absolute URL to the page or post on which the list appears, if any, with trailing slash

    Any ideas?
    Paul

    ageingdj

    (@ageingdj)

    This is very strange. It seems to be grouping the images but not at top levels. And not for every category, it only seems to be the lowest summary level (if you have TopLevel/second Level/Third level it will only perform the grouping on Third level and no grouping on on Top or First levels) but it still doesn’t show the post names on individual photos.
    I hope that makes sense
    Paul

    Plugin Author David Lingren

    (@dglingren)

    I regret the trouble you’re having with your caption values; thanks for your persistence.

    You wrote “{+featured_in_title+} returns blank“. You can verify the values by adding them as a column to the Media/Assistant submenu table. Go there and pull down the Screen Options (upper-right corner). Check the box to the left of the “Featured in” label to make the column visible. If you do that, do the appropriate values show up in the column for the images in your gallery?

    You wrote “I’ve tried most of what’s here“. Do all of those parameters return a blank value or do they return something that’s not what you want? I just tried {+page_title+} and is returns the proper value on my system. This is my parameter:

    mla_caption="{+title+} : {+date,date('d/m/Y')+} : {+featured_in_title+} : {+page_title+}"
    

    You wrote “It seems to be grouping the images but not at top levels.” I am not sure what you mean by “grouping the images”. As I understand it, the gallery will be sorted in descending ID order (i.e., most recent first) and divided into pages. The dropdown control will show the taxonomy hierarchy, but the gallery display will show a simple list of the items assigned to whatever term you select in the control. If I am not understanding you, any additional details will be helpful.

    Plugin Author David Lingren

    (@dglingren)

    It has been a month since my last post in this topic. I assume you have found a solution for your caption value application.

    I am marking this topic resolved, but please update if you have problems or further questions regarding the above suggestions. Thanks.

Viewing 15 replies - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.