• Resolved marchinbunny

    (@marchinbunny)


    Ok, so this is the shortcode I have been using and could had sworn it was working before. Basically I want the viewer to be able to sort by year (Basically I created 2017,2018,2019,2020 tags) using the tags while in the same category. As of now, when I click on the tag it no longer is sorted by the initial category “co” and just displays everything regardless of category under that tag.

    <center>[mla_tag_cloud]
    taxonomy=attachment_tag 
    mla_link_href="[+page_url+]?current_id={+term_id+}"
    number=0 smallest=12 largest=12 separator=' / ' minimum="1"
    [/mla_tag_cloud]</center>
    
    [mla_gallery] 
    attachment_category=co link="lightbox" orderby="date DESC" width="300" height="300"
    tax_query= "{+template:(array \\( 0 => array \\( 'taxonomy' => 'attachment_tag', 'field' => 'id', 'terms' => array\\( {+request:current_id+} \\) \\) \\))+}"
    mla_caption="{+image_alt+}" mla_alt_shortcode="su_custom_gallery" mla_alt_ids_name="source" mla_alt_ids_template="media: {+alt_ids+}"
    columns=5 posts_per_page=20 
    [/mla_gallery]
    
    [mla_gallery]
    attachment_category=co
    mla_output="paginate_links,prev_next"
    mla_link_class="nav-links"
    tax_query= "{+template:(array \\( 0 => array \\( 'taxonomy' => 'attachment_tag', 'field' => 'id', 'terms' => array\\( {+request:current_id+} \\) \\) \\))+}"
    columns=5 posts_per_page=20 size=full link=file
    [/mla_gallery]
Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter marchinbunny

    (@marchinbunny)

    So just a little bit more info. I have been messing around and I have found only tax_querys specifically are not accounting for the current category. If I use attachment_tag, it works fine. But of course I would prefer it the other way so I can have the images show up when the page loads.

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your question and the details of your current shortcodes; very helpful.

    I believe you can get the results you seek by replacing the tax_query with a simple taxonomy query. You will also have to change the current_id={+term_id+} query parameter in the [mla_tag_cloud] shortcode to current_id={+slug+}.

    I don’t have the su_custom_gallery shortcode so I can’t test exactly your shortcodes, but here is an alternative that should work for you:

    <center>[mla_tag_cloud]
    taxonomy=attachment_tag 
    mla_link_href="[+page_url+]?current_id={+slug+}"
    number=0 smallest=12 largest=12 separator=' / ' minimum="1"
    [/mla_tag_cloud]</center>
    
    [mla_gallery] 
    attachment_category=co
    attachment_tag="{+template:({+request:current_id+})+}"
    orderby="date DESC"
    posts_per_page=20 
    link="lightbox" width="300" height="300" columns=5
    mla_alt_shortcode="su_custom_gallery" mla_alt_ids_name="source" mla_alt_ids_template="media: {+alt_ids+}"
    [/mla_gallery]
    
    [mla_gallery]
    attachment_category=co
    attachment_tag="{+template:({+request:current_id+})+}"
    orderby="date DESC"
    posts_per_page=20
    mla_output="paginate_links,prev_next"
    mla_link_class="nav-links"
    [/mla_gallery]
    

    Note that I have re-ordered the shortcode parameters to more easily compare them. I have also removed several parameters which are not used in your case. As I said, I haven’t tested these specific shortcodes but they should work for you.

    The attachment_tag="{+template:({+request:current_id+})+}" parameter will be empty when the page loads, so it will be ignored until a term in the tag cloud is clicked. That will display all of the items in attachment_category=co.

    I am marking this topic resolved, but please update it if you have problems or further questions regarding the above suggestions. Thanks for your interest in the plugin.

    Thread Starter marchinbunny

    (@marchinbunny)

    Thank you! That’s exactly what I needed. I do happen to have another question, it’s about using minimum. I noticed the tags are still showing up despite there not being any images within them (within the category). Is it because there are images in it outside of the category? If there is no way around this, it’s all good. Not really a big problem.

    Plugin Author David Lingren

    (@dglingren)

    Thanks for confirming that my suggestion was helpful.

    You asked “I noticed the tags are still showing up despite there not being any images within them (within the category). Is it because there are images in it outside of the category?” Yes, that’s right. The item count assigned to a term is “global”, and does not include any filtering based on other criteria.

    Thanks for an interesting idea. I will have a look at the code and see if it’s feasible to make some enhancements, but I am not optimistic. I will post an update here if I decide to do something.

    Thread Starter marchinbunny

    (@marchinbunny)

    No problem, and thank you for your help. I greatly appreciate it. ??

    Thread Starter marchinbunny

    (@marchinbunny)

    Well, I ran into another problem using this method. I noticed the lightbox is no longer working unless you click on one of the tags (years) first.

    Actually you can ignore that, I switched to using Photonic and that works just fine.

    • This reply was modified 4 years, 7 months ago by marchinbunny.
    Plugin Author David Lingren

    (@dglingren)

    I have done some further thinking and testing and I believe I have a solution for you. The [mla_tag_cloud] shortcode accepts an ids= parameter with a list of attachment IDs. Only terms assigned to one or more of the IDs in the list are used for the cloud, which is what you want.

    To generate the list you can use the [mla_gallery] shortcode and the mla_alt_shortcode= parameter to filter your attachments by attachment_category=co and then hand off the IDs to [mla_tag_cloud].

    For your application, simply replace your existing [mla_tag_cloud] shortcode with this alternative:

    <center>[mla_gallery]
    attachment_category=co
    mla_alt_shortcode=mla_tag_cloud
    taxonomy=attachment_tag
    mla_link_href="[+page_url+]?current_id={+slug+}"
    number=0 smallest=12 largest=12 separator=' / ' minimum="1"
    [/mla_gallery]</center>
    

    Give that a try and let me know if it works for you. Thanks for an interesting application idea!

    Thread Starter marchinbunny

    (@marchinbunny)

    Thank you! It works great :).

    Thread Starter marchinbunny

    (@marchinbunny)

    Ok after testing it more, I found what seems to be a bug from what I can tell. Everything works well outside of the pagination I have at the bottom. If I select a page it messes with the tags at the top. Like for example, I may select page 3 and it will show the 2020 tag, but the 2019 tag disappeared. Then I select page 1 again to go back. And now only the 2019 tag shows. Basically, the only time all the tags seem to be there is when I am on the initial main page.

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your updates and for the testing you’ve done to track down the disappearing term cloud. This is easily fixed, and I regret the extra effort it caused you.

    In your current version all of the [mla_gallery] shortcodes are using the same default parameter to track the page number. The problem is that it is also “paginating” the first shortcode that creates the tag cloud. To fix it you must give the “real” gallery and pagination controls a different parameter name, e.g., mla_page_parameter=mla_gallery_current. Here are updated shortcodes; I’ve added the parameter just below posts_per_page:

    [mla_gallery] 
    attachment_category=co
    attachment_tag="{+template:({+request:current_id+})+}"
    orderby="date DESC"
    posts_per_page=20 
    mla_page_parameter=mla_gallery_current
    link="lightbox" width="300" height="300" columns=5
    mla_alt_shortcode="su_custom_gallery" mla_alt_ids_name="source" mla_alt_ids_template="media: {+alt_ids+}"
    [/mla_gallery]
    
    [mla_gallery]
    attachment_category=co
    attachment_tag="{+template:({+request:current_id+})+}"
    orderby="date DESC"
    posts_per_page=20
    mla_page_parameter=mla_gallery_current
    mla_output="paginate_links,prev_next"
    mla_link_class="nav-links"
    [/mla_gallery]
    

    Let me know if you still have problems after making this change. Be sure to make it to both of the last two shortcodes.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Need help’ is closed to new replies.