Support » Plugin: Media Library Assistant » combining taxonomies help

  • Resolved wonderwoman2

    (@wonderwoman2)


    Boy there is so much to this plugin – so much functionality!

    I’m stumped (by my own lack of knowledge).

    I have a page to display just one category of the media library and then display a tag cloud which lets people filter down to more specific groupings, and stay on the same page.

    What I’m a little stumped by is how to filter just the category and then the tags within that category.
    1st block – tag cloud
    2nd block – the documents
    3rd block – the pagination

    Here’s the coding I’m using (tweaked from your documentation):

    [mla_tag_cloud taxonomy=attachment_tag mla_link_href=”{+page_url+}?current_id={+term_id+}&mla_cloud_current={+template:({+request:mla_cloud_current+})|1+}” style=’masonry’ separator=” · ” smallest=12 largest=12]

    [mla_gallery post_mime_type=application/pdf tax_query=”array ( 0 => array ( ‘taxonomy’ => ‘attachment_tag’, ‘field’ => ‘id’, ‘terms’ => array( {+request:current_id+} ), ‘include_children’ => false ) )” mla_caption=”{+title+}” columns=5 size=icon link=file posts_per_page=10 ]

    [mla_gallery post_mime_type=all tax_query=”array ( 0 => array ( ‘taxonomy’ => ‘attachment_category’, ‘field’ => ‘id’, ‘terms’ => array( {+request:current_id+} ), ‘include_children’ => false ) )” columns=5 posts_per_page=10 mla_output=”paginate_links,prev_next”]

    The issue is in the 2nd block.
    I’m using the query for the attachment_tag which gives me exactly the behaviour I’m after. The only thing is I need the display to only show a specific attachment_category.

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

    (@dglingren)

    Thanks you for your good words regarding the plugin and for your question. Thanks as well for including the full source text of your shortcodes; very helpful.

    Here are updated shortcodes that are working well on my test system:

    [mla_tag_cloud taxonomy=attachment_tag post_mime_type=application/pdf minimum=1 mla_link_href="{+page_url+}?current_id={+term_id+}&mla_cloud_current={+template:({+request:mla_cloud_current+})|1+}" style='masonry' separator=" · " smallest=12 largest=12]
    
    [mla_gallery post_mime_type=application/pdf tax_query="array ( 'relation' => 'AND', array ( 'taxonomy' => 'attachment_tag', 'field' => 'id', 'terms' => array( {+template:({+request:current_id+})|1+} ), 'include_children' => false ),  array ( 'taxonomy' => 'attachment_category', 'field' => 'slug', 'terms' => 'abc', 'include_children' => false ) )" posts_per_page=10 mla_caption="{+title+}" columns=5 size=icon link=file ]
    
    [mla_gallery post_mime_type=application/pdf tax_query="array ( 'relation' => 'AND', array ( 'taxonomy' => 'attachment_tag', 'field' => 'id', 'terms' => array( {+template:({+request:current_id+})|1+} ), 'include_children' => false ),  array ( 'taxonomy' => 'attachment_category', 'field' => 'slug', 'terms' => 'abc', 'include_children' => false ) )" posts_per_page=10 mla_output="paginate_links,prev_next"]
    

    My changes are:

    1. I added post_mime_type=application/pdf and minimum=1 to block 1. This restricts the cloud display to those terms that have one or more PDF documents assigned to them. I regret that there is no explicit way to further restrict the cloud to terms within a single category.
    2. I added a second element to the tax_query, array ( 'taxonomy' => 'attachment_category', 'field' => 'slug', 'terms' => 'abc', 'include_children' => false ), to restrict the gallery display and pagination controls to items assigned to the ‘abc’ term in the attachment_category taxonomy. You can adapt this element to the term you want.
    3. I added a 'relation' => 'AND' element to the tax_query so items must have both the ‘abc’ term and the term from the cloud to be displayed.
    4. I have changed the attachment_terms value to {+template:({+request:current_id+})|1+} so the gallery will be empty until a cloud term is clicked.
    5. I ensured that the data selection parameters for block 2 and block 3 are identical, so the controls will match the gallery display.
    6. I removed the columns=5 parameter from the pagination controls, which do not use this parameter.

    You can restrict your tag cloud, block 1, to terms assigned to item having attachment_category=abc by adapting a two-step shortcode combination:

    [mla_gallery post_mime_type=application/pdf post_parent=all category=abc mla_alt_shortcode=mla_tag_cloud mla_alt_parameters="taxonomy=attachment_tag mla_link_href='{+page_url+}?current_id={+term_id+}&mla_cloud_current={+template:({+request:mla_cloud_current+})|1+}' style='masonry' separator=' · ' smallest=12 largest=12"]
    

    In this alternative the [mla_gallery] shortcode selects all PDF documents assigned to attachment_category=abc and then passes a list of their ID values as an ids= parameter to the alternate shortcode, [mla_tag_cloud]. The cloud then displays only those terms assigned to one or more of the items in the list. You can find more information in the “Support for Other Gallery-generating Shortcodes” section of the Settings/Media Library Assistant Documentation tab.

    I hope that gets you started on a solution that works for your application. 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.

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