• Resolved 1ore

    (@1ore)


    First, I want to thank you for providing such thorough and thoughtful documentation for this plugin. I am currently moving my art website to a WordPress site, and, having only worked with html+css to this point, your documentation has been extremely helpful in bridging the gap. I have learned a lot in the process and feel much more confident than when I started : -) thank you so much, people like you are truly the glue keeping society together.

    As for why I’m here in the support forum… I’ve been able to figure things out to this point, but I think I’m finally out of my depth. I am putting together a paginated gallery using the core plugin and the MLA UI Elements Example plugin. It sorts galleries by year and pulls links to posts of a custom post type / taxonomy. So far, this has been doing the trick for me:

    [muie_archive_list verses='moribund' post_type=works post_status=publish post_mime_type=all post_parent=all archive_type=yearly archive_output="paginate_archive,prev_next" prev_text="?? Forth" next_text="Back ??"]
    
    [mla_gallery verses='moribund' post_type=works post_status=publish post_mime_type=all post_parent=all size=medium orderby="date DESC" archive_parameter_name=muie_current_archive]

    My challenge has been cleaning up the URLs to each generated page. Currently, they look something like:

    blablabla.com/moribund-art/?muie_current_archive=post_date%2CY%282022%29

    (“moribund-art” being a page.)

    I would like to clean up the queries, if I can. Something like:

    blablabla.com/moribund-art/?date=2022

    or even
    blablabla.com/moribund-art/2022

    I have played around with WordPress’s native “wp rewrite” rules and the Redirection plugin, but changing the urls manually breaks the connectivity between the paginated pages. (Which makes sense, but this goes to show my inexperience with these languages.)

    After closer reading of the plugin guide, I think(?) it may be possible to do some of this from within the MLA plugin instead, by renaming some parameters or making some substitutions (mla_link_href?) but I can’t quite wrap my head around how to go about this.

    If this is indeed possible, any pointers in the right direction or resources for further reading would be tremendously appreciated. No worries if not, I’m sure I can cobble something together with time. I hope that you are having a good start to your week!

    • This topic was modified 1 year, 6 months ago by 1ore. Reason: markup cleanup
Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author David Lingren

    (@dglingren)

    Thank you for your generous and positive comments on the plugin and its documentation. Thanks as well for finding and applying the MLA UI Elements Example plugin in an interesting and creative way.

    Resolving the URL encoding of the generated URLs gives you something like this:

    muie_current_archive=post_date,Y(2022)

    The shortcode looks in the PHP $_REQUEST array for the muie_current_archive element; that triggers processing. The element value contains the database field to query, the archive type and the value to filter by. Any alternative URL you generate must be converted back to this name and format for the shortcode to work.

    The Redirection plugin is excellent. You may be able to use the redirection_request_url filter it provides (and some PHP code) to detect your URL format and convert it to the format the example plugin requires. If that works I will have to make some changes in the example plugin so you can reformat the links in the pagination controls. In the current version the link_href shortcode parameter allows you to modify the URL portion of the link, but the muie_current_archive query argument cannot be modified. If you can get the Redirection plugin filter working I will work on the link query argument fix.

    I hope that helps get you started. Let me know if you think the above approach is workable. Thanks.

    Thread Starter 1ore

    (@1ore)

    Hi there, just wanted to quickly say thank you so much for your help! It really means a lot, especially for a wordpress + PHP greenhorn (: this was extremely helpful in pointing me in the right direction.

    Speaking to that, I *think* I have written some PHP that has Redirection and Media Library Assistant talking to each other, but I wanted to spend some more time with it, just to be sure that it’s working properly and that I understand it. As you can see from the lateness of this reply, time has been on a premium lately hahahaha. I’ll be in touch as soon as I can give it another look. Thanks again!

    Thread Starter 1ore

    (@1ore)

    OK, turns out that day would be today. After much fiddling, I *think* everything is working as it should.

    So, the Archive plugin constructs a page with the URL: https://m0r1bund.local/moribund-art/?muie_current_archive=post_date%2CY(2021)

    Redirection converts the above URL to the desired URL: https://m0r1bund.local/moribund-art/2021/

    (To keep it simple I decided to target this specific URL, as I haven’t quite gotten regex to cooperate with encoded/decoded URLs yet.)

    … And then I have a PHP snippet that converts it back into the original URL, using Redirection’s redirection_request_url filter.

    add_filter( 'redirection_request_url', function( $url ) {
    
      return 'm0r1bund.local/moribund-art/?muie_current_archive=post_date,Y(2021)';
    
    }, 10, 2 );

    I hope I understood what you were meaning correctly. Learning coding is very “monkey see, monkey do” for me, so to be honest, I am mystified at how this filter knows when and when not to fire ??

    • This reply was modified 1 year, 6 months ago by 1ore.
    Plugin Author David Lingren

    (@dglingren)

    Thanks for digging in to my suggestions and working with the Redirection plugin.

    First, my apologies for leading you off track and into the redirection_request_url filter, which turns out to be unnecessary and, in fact, doesn’t work for this application. All you need in Redirection is a rule with the proper Regular Expression; no filters or PHP code required. Here is a rule which should give you the results you need:

    Source URL: /moribund-art/([0-9]{4,4})
     Target URL: https://m0r1bund.local/moribund-art/?muie_current_archive=post_date%2CY%28$1%29

    Don’t forget to check the “Regex” box to enable the Regular Expression. In this rule, the ([0-9]{4,4}) portion extracts to four-digit year from the source URL. The $1 portion of the target URL is replaced by the value extracted from the source. Mission accomplished.

    As I wrote in my first post, some modifications to the MLA UI Elements Example plugin are required to reformat the pagination links as you desire. The current version always adds the muie_current_archive query argument to the URL, which you don’t want. I have added a new parameter, append_current_item, to fix the problem.

    I have uploaded a new MLA Development Version dated 20230909 that includes the updated example plugin. 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 must update the example plugin. Navigate to the Settings/Media library Assistant Documentation tab and click the “Example Plugins” button. Type “elements” 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 “update” rollover action, then go to the WordPress Plugins/Installed Plugins submenu and make sure you have the latest version, 2.06, installed.

    Once the Development Version and updated example plugin are installed and active you can modify your shortcode to get the “clean” links:

    [muie_archive_list verses='moribund' post_type=works post_status=publish post_mime_type=all post_parent=all archive_type=yearly archive_output="paginate_archive,prev_next" prev_text="?? Forth" next_text="Back ??" link_href="{+page_url+}{+year+}" append_current_item=false]

    The [mla_gallery] shortcode is unchanged. I made two changes to the shortcode above. First, link_href="{+page_url+}{+year+}" changes the hyperlink format to your clean alternative. Second, the append_current_item=false parameter suppresses the addition of the current item query argument.

    The enhanced 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 1ore

    (@1ore)

    I have only just installed it, but from what I can tell, it works like a charm! I keep tabbing back and forth between pages and grinning like an idiot. Thank you so much for this, I don’t know where I would be without your help. I kicked some change over to your Chateau Seaview Fund and am very moved that you give so much to strangers on the internet. Thank you!


    (Also, just wanted to add this in case someone uses this example plugin and has the same thought that I did. When setting the redirection in the redirection plugin, the landing page will serve the target “?muie_current_archive=”-format URLs, unless you pop open the advanced settings and change the redirect action to “pass-through.” This will retain the source/reformatted URLs in the searchbar even after the page is redirected : -) )

    Plugin Author David Lingren

    (@dglingren)

    Thanks for giving the Development Version a try and confirming that the enhancements work as expected. Thanks as well for the kind words and especially for the donation to our charitable fund; every dollar goes to people who really need it. Donations, reviews and positive feedback are great incentives to keep working on the plugin and supporting its users.

    And yes, the “When matched” advanced setting should be changed to “Pass-through”, as you noted. Good catch.

    Plugin Author David Lingren

    (@dglingren)

    I have released MLA version 3.11, which contains the enhancements required for this topic.

    I am marking this topic resolved, but please update it if you have any problems or further questions regarding MLA’s support for customizing the URLs in the [muie_archive_list] shortcode. Thanks for inspiring this MLA improvement.

    Thread Starter 1ore

    (@1ore)

    So sorry to open this up again, especially so soon. I’ve been having a blast with the new shortcode, but have had one hiccup that I’m not sure how to navigate. I figured I would forward it to you in case you had any insight.

    I seem to hit performance issues(?) when several posts from across multiple years are queried by the gallery pagination shortcode. Sometimes the redirection will hang for a few seconds, and then either the white screen of death appears, or the gallery page renders without pagination. Interestingly, this doesn’t occur when the redirection is set as a normal redirection rather than a pass-through one—the normal redirect works like a charm.

    I say “performance issues(?)” because as far as I can tell, neither of the plugins exceed the memory that WordPress allots to them. I’m playing with about 10 posts, dated across 5 or 6 years. Most have images attached.

    I managed to recreate the issue on my personal website and a testing one (Fresh WordPress installation, default twentytwentythree theme, with just MLA + MLA UI Elements + Redirection as plugins.) I have tried to be conscientious of caching as well, but I’m just now learning how many caches exist outside of my browser one ?? Not sure how helpful pictures are in this situation, but here’s a screenshot of the testing environment and shortcodes:

    Interestingly, things seem to work better when the same number of posts are sorted into a shorter timespan of two or three years. But maybe that’s my imagination?

    In any case, I realize this is a lot of work for a short string of letters and slashes, so I’m happy to leave them as standard redirects for now. Thank you so much for your time and all that you do!

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your update and the details of what you are experiencing. You never have to feel sorry for alerting me to new symptoms.

    I have set up a separate site along the lines of your testing site. The redirections are taking around 8 seconds, as you experienced. I will investigate further and post an update when I have some results to share.

    Plugin Author David Lingren

    (@dglingren)

    I ran many tests and it looks like the Redirection plugin is adding to the response time. I don’t think there’s anything MLA can do about that.

    On my system, when Redirection matches the URL and replaces the query argument there is a four-second delay. Because my site has the “Day and name” Permalink structure, there is a second redirection which also adds a second four-second delay to this “matched and replaced” page load. The WordPress redirection does not cause any delay in other page loads, only when the URL is matched and replaced.

    If you change the Redirection rule to match your Permalink structure you may eliminate some of the delay.

    You can also experiment with a different redirection plugin:

    Redirection – WordPress plugin | www.remarpro.com

    The name is confusingly identical, but it’s a different plugin by another organization. It may perform better – I have not had a chance to try it.

    Let me know if any of that helps.

    Thread Starter 1ore

    (@1ore)

    Thank you, David! I suspected that might be the case, since we’re playing hot potato with the links. I will play around with Redirection #2 and the link structure, but I’m also just happy with being able to use the alternate links at all : -) You are a life-saver and I appreciate you and all that you do!

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Cleaning up URL queries in paginated gallery pages’ is closed to new replies.