• Resolved petehobden

    (@petehobden)


    Hi David,

    It’s an impessive body of work you created!

    I have a question re pagination.
    I based my shortcodes on your single-sample example in your documentation.
    My question : is there a way to get the current id from the pagination part of the shortcode without passing it in a url argument?
    I have seperate pages for each image. Apparently the attachment tag can be specified in the shortcode instead of in the url argument.
    Here are my shortcodes:

    For the image:

    [mla_gallery] 
    	mla_style=featuredpainting
    	mla_markup=featured-np
    	s={+page_name+}.jpg
    	/*attachment_tag=featured*/
    	/*ids={+attachment_ID+}*/
    	mla_search_fields=file
    	whole-word=true
    	size=large
    	columns=1
    	mla_caption='<a href="/painting-views/?filename={+page_name+}detail">►See a detail of the painting</a> "{+post_id+}"</br></br><strong>{+description+}</strong> </br></br> {+caption+} </br>  {+custom:LocationCity+} {+custom:LocationProvince+} {+custom:LocationCountry+} </br></br><small>click on image to see full size</small>'
    [/mla_gallery]

    For the pagination:

    <div style="clear: both; float: left;margin-left:10% !important;font-size: calc( 7px + 0.50vw) !important;">
    [mla_gallery]
    	mla_output="previous_link,wrap" 
    	attachment_tag="featured"
    	id="{+request:current_id+}"
    	mla_link_text='&larr; {+post_id+}{+title+}'
    	mla_link_href="/featured-paintings/{+name_only+}/?current_id={+attachment_ID+}"
    [/mla_gallery]
    </div>
    
    <div style="float: right; margin-right:10% !important; font-size: calc( 7px + 0.50vw) !important;">
    [mla_gallery]
    	mla_output="next_link,wrap"
    	attachment_tag="featured" 
    	id="{+request:current_id+}"
    	mla_link_text='{+title+} &rarr;'
    	mla_link_href="/featured-paintings/{+name_only+}/?current_id={+attachment_ID+}"
    [/mla_gallery]
    </div>

    Thank you

    Peter
    PS: Hope things work out well for you.

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

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

    (@dglingren)

    Good to hear from you again. Thanks for the positive MLA feedback and for your question. Thanks as well for including the full text of the shortcodes you are using and the link to the page you need help with; very helpful.

    It took me a while to understand your question and what you meant by the “current id”. The page you need help with is based on this earlier topic you authored:

    Create a page with an image based on page slug

    Your page contains an [mla_gallery] shortcode that displays a single image whose file name matches the page name/slug. You have pagination links to the previous and next images in a set that includes all images assigned to the attachment_tag=featured term. You want to know the “attachment_ID” value of the displayed image in the pagination shortcodes to compute links the previous and next images in the set.

    The solution is somewhat complicated and a bit inefficient, but you can use MLA’s “Support for Other Gallery-generating Shortcodes” to accomplish your goal. Basically, you use [mla_gallery] to perform the name/slug search, the pass the ID of the selected image to a second (alternate) [mla_gallery] shortcode that uses the value to generate the pagination. You can replace your current pagination shortcodes with these new versions:

    <div style="clear: both; float: left;margin-left:10% !important;font-size: calc( 7px + 0.50vw) !important;">
    [mla_gallery]
    s={+page_name+}.jpg
    mla_search_fields=file
    whole_word=true
    mla_alt_shortcode=yes
    mla_alt_ids_name=id
    mla_alt_parameters='mla_output="previous_link,wrap" attachment_tag="featured" mla_link_text="&larr; {+post_id+}:{+title+}" mla_link_href="/featured-paintings/{+name_only+}/"'
    [/mla_gallery]
    </div>
    
    <div style="float: right; margin-right:10% !important; font-size: calc( 7px + 0.50vw) !important;">
    [mla_gallery] 
    s={+page_name+}.jpg
    mla_search_fields=file
    whole_word=true
    mla_alt_shortcode=yes
    mla_alt_ids_name=id
    mla_alt_parameters='mla_output="next_link,wrap" attachment_tag="featured" mla_link_text="{+title+} &rarr;" mla_link_href="/featured-paintings/{+name_only+}/"'
    [/mla_gallery]
    </div>

    Note that I have corrected the whole_word paremeter to use an underscore instead of a dash; make that change in your gallery shortcode, too.

    In developing and testing this solution I discovered an MLA defect in the way parameters are processed when [mla_gallery] is used as the alternative shortcode. I have uploaded a new MLA Development Version dated 20240512 that corrects the problem. You can find step-by-step instructions for using the Development Version in this earlier topic:

    How to download & install the current development version of MLA

    Once the Development Version is installed you can implement and test the above solution.

    The fix will be part of my next MLA version, but in the interim it would be great if you could install the Development Version and let me know if it works for you. Thanks for alerting me to this MLA defect. If you have any problems or further questions regarding my suggested solution, post an update and I will continue the work.

    Thread Starter petehobden

    (@petehobden)

    Thank you for your reply and solution.
    I have tried it without installing the development version of MLA.
    The pagination links seem to work fine.
    I presume the defect you mention :

    an MLA defect in the way parameters are processed when [mla_gallery] is used as the alternative shortcode

    is the fact that the MLA short code is dispalayed by the browser? I will soon install the development version you mention and report back.

    Thread Starter petehobden

    (@petehobden)

    I have now installed the development plugin and everything works Perfectly. Thank you.

    I don’t really understand the mechanism of of mla_alt_shortcode. Who is processing the alternate parameters? Not an urgent question, the essential thing is that it works.
    In any case thanks again for the help

    Plugin Author David Lingren

    (@dglingren)

    Thanks for confirming that the Development Version is working for you. Regarding your question, the “alternate shortcode” in this solution is also[mla_gallery]. It’s a bit confusing because the special mla_alt_shortcode=yes parameter is not exactly self-documenting. The mla_alt_parameters parameter is required to “hide” the parameters from the first [mla_gallery] processing and pass them on directly to the second [mla_gallery] processing.

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