• Resolved alx359

    (@alx359)


    Hello David,

    Would be really nice to have the Att. Categories column to be sortable. With a large media gallery, getting the images with no Att. Categories terms on top would be of great help to address an issue.

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

    (@dglingren)

    Good to hear from you again, and thanks for the question. I have had the same thought from time to time, but cannot think of a good solution.

    There are two immediate problems. First, items can have multiple terms assigned – which value would you sort on? Second, sorting the table is part of the WP_Query database query, but this does not have an option to sort on taxonomy terms. The current MLA version uses a separate WordPress function call to retrieve the terms after the database query is complete.

    You wrote “getting the images with no Att. Categories terms“. If you are filtering the Media/Assistant submenu table on Att. Categories (i.e. you see a dropdown control with “All Att. Categories” in the middle of the toolbar) you can select “No Att. Categories” and then click “Filter” to display only those items having no term assignments. Perhaps that will satisfy your immediate needs.

    You could also define a Custom Field mapping rule to copy term assignments to a custom field, then display and sort on the custom field. If this is an occasional need you can inactivate the rule and purge the field values until they are required.

    I am marking this topic resolved simply because the question has been answered to the best of my ability. I regret the news is not better but I hope you find the suggested workarounds helpful. Thanks for your continued interest in the plugin.

    Thread Starter alx359

    (@alx359)

    Thanks for your detailed and thoughtful as always response, David.

    First, items can have multiple terms assigned – which value would you sort on?

    Think the value added by such a column sorting feature would become apparent if we take them all at once as a single string. For example:

    
    'A1 Prints, Family'
    'A1 Prints, Family'
    <all remaining 'A1 Prints, Family' rows>
    ...
    'A3 Prints, Angels'
    'A3 Prints, Angels'
    <all remaining 'A3 Prints, Angels' rows>
    ...
    

    As MLA seems to already display terms in an ordered manner (according to their positions in the Att. Categories tree) think a terms-as-a-string column sorting feature would make sense to produce grouped sets of rows as an additional view on the data, which the filter and search facility cannot exactly achieve.

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your update with the suggested solution. To try out your “terms-as-a-string” idea I defined a Media/Assistant custom table column and a custom view as outlined in my earlier post. First, the custom table column:

    1. Navigate to the Settings/Media Library Assistant “Custom Fields” tab.
    2. Scroll down to the “Add New Custom Field Rule” section on the left-hand side of the page.
    3. Click the “Enter new field” link and enter the name of your field, e.g. “Att Cat Terms”.
    4. Set the Data Source dropdown set to “– Template (see below) –”.
    5. Enter “[+terms:attachment_category+]” in the Meta/Template text box.
    6. Check the “MLA Column” box to display the field as a column in the Media/Assistant submenu table.
    7. Leave the “Quick Edit” and “Bulk Edit” boxes unchecked.
    8. Select “Replace” for “Existing Text”.
    9. Select “Native” for “Format”.
    10. Select “Text” for “Option”.
    11. Check the “Delete NULL Values” box.
    12. Leave the “Status” dropdown set to “Active”
    13. Click “Add Rule” to create the new rule.

    Once that’s done, find the rule in the submenu table, hover over the rule hane and click the “Execute” action to populate the custom field. When you return to the Media/Assistant admin page you will see a new, sortable column containing the term values. My system has many items with no terms assigned, so I created a custom view to filter them out:

    1. Navigate to the Settings/Media Library Assistant “Views” tab.
    2. Scroll down to the Add New View area on the left side of the page.
    3. Enter something like “a-c-terms” in the Slug field.
    4. Enter something like “Att. Cat. Terms” in the Singular and Plural Label fields.
    5. Enter “custom:Att Cat Terms=*” (without the quotes) in the Specification field.
    6. Leave the Post MIME Type box unchecked, since this is not a MIME type.
    7. Check the Table View box, to add this as a Media/Assistant view.
    8. Leave the Menu Order blank, unless you want to position the column in a specific place. (unusual)
    9. Enter any notes you like in the Description box, or leave it blank.
    10. Click “Add View” to add your view to the custom views list.

    Return to the Media/Assistant admin page and you will see the new view above the submenu table. Click on it to eliminate items with no terms assigned from the table.

    On my system, the “terms-as-a-string” grouping didn’t always make sense. Many items are assigned to more than one top-level term and the column did not group them in a useful way. The term structure on your site is very logical and the the “terms-as-a-string” grouping might work very well. I am not sure it works well in general, though.

    The custom field approach also avoids the second problem I identified: “sorting the table is part of the WP_Query database query, but this does not have an option to sort on taxonomy terms”. To implement “terms-as-a-string” in an automatic, dynamic way would require custom database queries and have a noticable performance impact on larger sites.

    As I wrote earlier, I have not been able to find a general solution that would work well for all MLA users. I hope you find the custom field approach useful for your site.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Att. Categories sortable’ is closed to new replies.