WordPress.org

Ready to get started?Download WordPress

Forums

Media Library Assistant
[resolved] Search by parent (21 posts)

  1. jorgeorpinel
    Member
    Posted 1 year ago #

    In the Media Library Assistant list, it would be greatly useful to have another checkbox for "parent" meaning the parent post's title or perhaps slug. Or is there another way to list in the assistant all the media items in a post?

    http://wordpress.org/extend/plugins/media-library-assistant/

  2. David Lingren
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks for your interest in the plugin and your question.

    There are two columns you can add to the Media/Assistant submenu table listing that might help; "Parent ID" and "Attached to". Parent ID is what you'd expect; the numeric post ID of the attachment's parent post or page. The "Attached to" column displays the parent's title - I think that's what you're looking for. You can sort on either of these columns to group all the attachements with a common parent.

    The big difference in the two columns is what happens when you click the column's value for a particular parent. The "Parent ID" column contains a link that will filter the Media/Assistant submenu on the ID, i.e., it will display all the attachments with that parent. The "Attached to" column will display the post/page edit page for the parent (that's what the WordPress Media/Library submenu does).

    I hope one or both of those columns contain the information you're looking for. If not, let me know what's missing and I will see if there's something else I can do.

  3. jorgeorpinel
    Member
    Posted 1 year ago #

    David, you're welcome and many thanks on your answer! What you described does solve my need :)
    I would still suggest to add the search-by-parent (name/slug) feature to avoid having to manually search a list ordered by "Parent ID" or "Attached to".
    Great work on the plugin!

  4. jorgeorpinel
    Member
    Posted 1 year ago #

    Well, actually from what David said earlier it can be said that you CAN "search" by parent (or rather all media in a post) if you know the post's ID (which is easy), just use the following URL:

    .../wp-admin/upload.php?page=mla-menu&parent=1828

    Changing 1828 for the post's ID.

  5. David Lingren
    Member
    Plugin Author

    Posted 1 year ago #

    Yes, your URL suggestion works, but it's inconvenient. I have just added an easier method to my next release. Simply enter the ID in the "Search Media" box in the upper-right corner of the Media/Assistant submenu screen. A numeric entry in the Search Box will match either the attachment ID or the Parent ID (post_parent).

    Thanks for the suggestion!

  6. David Lingren
    Member
    Plugin Author

    Posted 1 year ago #

    I have released version 1.20, which includes:

    * New: If the search box contains (only) a numeric value it is interpreted as a search by attachment ID or parent ID (post_parent). You can search for a numeric value in the text fields, e.g., title, by putting quotes around the value.

    Thanks again for the idea.

  7. jorgeorpinel
    Member
    Posted 1 year ago #

    Wow that sounds great! I'm updating asap.

    p.s. I think you mean textual the second time you say numeric :)

  8. David Lingren
    Member
    Plugin Author

    Posted 1 year ago #

    Well, I guess I could say "search for the textual representation of a numeric value"...

    If you enter a number without the quotes, it won't search the text fields at all - it goes straight to the ID and post_parent fields.

    Anyway, you get the idea. Enjoy the new release!

  9. jorgeorpinel
    Member
    Posted 1 year ago #

    Oh I see! I was actually interpreting you differently before. I thought a search string with quotes would look in post titles instead of media titles. Haha anyway, cool! Thanks for the reply.

  10. jorgeorpinel
    Member
    Posted 1 year ago #

    Hello again David.

    This is not working for me anymore (still in version 1.20). I'm searching for 2086 or "2086' or "2086" (id of post called "008-1930") and can't find anything :( Am I doing something wrong?

    Here's a couple screenshots that show (1) my search vs. (2) filtering by clicking on the parent:2086 link (after finding a media item in the unfiltered list)

    1. https://docs.google.com/file/d/0B7JEImS_HANHdHR3cldFYUVBVEE/edit?usp=sharing
    2. https://docs.google.com/file/d/0B7JEImS_HANHTUhCSFlGNlpnQmc/edit?usp=sharing

    Thanks and best regards.

  11. David Lingren
    Member
    Plugin Author

    Posted 1 year ago #

    If you enter a numeric value in the Search box, e.g., 2086 without any single or double quotes or other characters, MLA will search for a match by post ID or post_parent. If you put single or double quotes around the value, or if you enter anything other than digits in the search box, MLA will search for those characters in the text fields such as Description.

    The screen shot search results for "'2086'" has single quotes around the value, so it's a text search, not an ID search.

    I just re-tested this in v1.30 and it's working on my system; it should also work in v1.20. Give it another try entering just the numeric digits. If it's still not working, try searching for an image, e.g., 9042, 9043. Let me know one or both of those are not working for you.

  12. jorgeorpinel
    Member
    Posted 1 year ago #

    Sorry for the delayed response.

    I updated to 1.30 in case that was a problem (I was having other difficulties which were fixed that way) but unfortunately I can't figure out the search by ID or parent.

    Here's MLA listing the 1st item as 263: https://docs.google.com/file/d/0B7JEImS_HANHUktpQ293enNmT0U/edit?usp=sharing
    and here's a search (from that last screen) of the ID without quotes and trying every field joined by 'or' (also tried the default setting of title & description having same result: https://docs.google.com/a/orpinel.com/file/d/0B7JEImS_HANHcEY4M1FjWmJnYlU/edit?usp=sharing

    Not a big deal.

  13. David Lingren
    Member
    Plugin Author

    Posted 1 year ago #

    Maybe not a big deal, but an issue none the less. I'm puzzled, because it's s simple feature and (of course) it works on my test systems. I assume that the problem is limited to the search box - do the links in the Parent/ID column perform the search properly?

    I'll go back thru the code and see if anything else occurs to me. Maybe I can add some debugging information we can use to gather more data. I will keep you posted on my investigation.

  14. jorgeorpinel
    Member
    Posted 1 year ago #

    Yes. links in the Parent/ID column perform the search properly going to ...wp-admin/upload.php?page=mla-menu&parent=1828&heading_suffix=Parent%3A+002-2010 (which I can just modify and reuse for parend id searches directly with the URL for now, basically with the &parent=xxxx argument)

    The search box doesn't work, going to ...wp-admin/upload.php?s=1828&mla-search-submit=Search+Media&mla_search_connector=AND&mla_search_fields%5B%5D=title&mla_search_fields%5B%5D=content&page=mla-menu&m=0&_wpnonce=73c89cc6d3&_wp_http_referer=%2Fcms%2Fwp-admin%2Fupload.php%3Fs%26mla_search_connector%3DAND%26mla_search_fields%255B0%255D%3Dtitle%26mla_search_fields%255B1%255D%3Dcontent%26page%3Dmla-menu%26m%3D0%26mla_filter_term%3D3747%26mla_filter%3DFilter%26paged%3D1&action=-1&m=0&mla_filter_term=3747&paged=1&action2=-1

  15. David Lingren
    Member
    Plugin Author

    Posted 1 year ago #

    Well, that's interesting, and helpful. Thanks for thinking of sending the URL value!

    Towards the end of the "search box" URL string you can see mla_filter_term=3747. That implies that you have selected an "Att. Category" value from the drop-down list next to the "Filter" button. If you did, the Att. Category value would be added to the search criteria and an attachment would have to have BOTH parent=1828 AND attachment_category=3747 to be displayed.

    Does that make sense? Did you do any category filtering in addition to (or prior to) trying the parent search?

    By the way, I have added some debugging code to version 1.40, which I released last night. If you add ">|<" in front of your search value, e.g., ">|<1828", you will get about 14 "Warning:" messages with information I would find most helpful. If you add "<|>" in front of the search all those messages will go to the PHP error log and not clutter up the display. When you upgrade to v1.40, give that a try and send me the results.

    I can't make the combination of category filtering and searching fail on my system, but I think we're on to something and I will keep at it. Thanks for your ongoing help and your patience!

  16. jorgeorpinel
    Member
    Posted 1 year ago #

    Always a pleasure DAvid.

    Towards the end of the "search box" URL string you can see mla_filter_term=3747. That implies that you have selected an "Att. Category" value from the drop-down list next to the "Filter" button

    I may have filtered that time but even if I don't I get no results. I entered 1828 right off ...wp-admin/upload.php?page=mla-menuand the resulting URL was ...wp-admin/upload.php?s=1828&mla-search-submit=Search+Media&mla_search_connector=AND&mla_search_fields%5B%5D=title&mla_search_fields%5B%5D=content&page=mla-menu&_wpnonce=36e6224824&_wp_http_referer=%2Fcms%2Fwp-admin%2Fupload.php%3Fpage%3Dmla-menu&action=-1&m=0&mla_filter_term=0&paged=1&action2=-1 (no results) so I don't think the filtering is related to the problem I'm experiencing.

    I installed 1.40 and tried >|<1828 in the search box. I get a lot of warnings! Here they are :)

    Warning: mla_query_posts_search_filter search = '1828' in ..wp-content/plugins/media-library-assistant/includes/class-mla-data.php on line 724
    
    Warning: mla_query_posts_search_filter $search_clause = ' AND ( ( cms_posts.ID = 1828 ) OR ( cms_posts.post_parent = 1828 ) ) ' in ..wp-content/plugins/media-library-assistant/includes/class-mla-data.php on line 740
    
    Warning: _execute_list_table_query $request = array ( 'm' => 0, 'orderby' => 'post_parent', 'order' => 'ASC', 'post_type' => 'attachment', 'post_status' => 'inherit', ) in ..wp-content/plugins/media-library-assistant/includes/class-mla-data.php on line 675
    
    Warning: _execute_list_table_query self::$query_parameters = array ( 'use_postmeta_view' => false, 'orderby' => 'post_parent', 'order' => 'ASC', 'detached' => false, 'debug' => 'console', 's' => '1828', 'mla_search_connector' => 'AND', 'mla_search_fields' => array ( 0 => 'title', 1 => 'content', ), 'sentence' => false, 'exact' => false, 'postmeta_key' => '_wp_attachment_image_alt', ) in ..wp-content/plugins/media-library-assistant/includes/class-mla-data.php on line 676
    
    Warning: _execute_list_table_query $results->request = 'SELECT SQL_CALC_FOUND_ROWS cms_posts.* FROM cms_posts WHERE 1=1 AND ( ( (cms_posts.post_title LIKE "%>|<1828%") OR (cms_posts.post_content LIKE "%>|<1828%")) OR ( cms_posts.post_parent IN ( select ID from cms_posts as b where b.<code>post_type</code> <> "attachment" and b.<code>post_title</code> like "%>|<1828%" ) ) ) AND cms_posts.post_type = "attachment" AND (cms_posts.post_status = "inherit" OR cms_posts.post_status = "private") ORDER BY cms_posts.post_date DESC LIMIT -200, 200' in ..wp-content/plugins/media-library-assistant/includes/class-mla-data.php on line 677
    
    Warning: _execute_list_table_query $results->post_count = 0 in ..wp-content/plugins/media-library-assistant/includes/class-mla-data.php on line 678
    
    Warning: _execute_list_table_query $results->found_posts = 0 in ..wp-content/plugins/media-library-assistant/includes/class-mla-data.php on line 679
    
    Warning: mla_query_posts_search_filter search = '1828' in ..wp-content/plugins/media-library-assistant/includes/class-mla-data.php on line 724
    
    Warning: mla_query_posts_search_filter $search_clause = ' AND ( ( cms_posts.ID = 1828 ) OR ( cms_posts.post_parent = 1828 ) ) ' in ..wp-content/plugins/media-library-assistant/includes/class-mla-data.php on line 740
    
    Warning: _execute_list_table_query $request = array ( 'm' => 0, 'orderby' => 'post_parent', 'order' => 'ASC', 'post_type' => 'attachment', 'post_status' => 'inherit', 'offset' => 0, 'posts_per_page' => '200', ) in ..wp-content/plugins/media-library-assistant/includes/class-mla-data.php on line 675
    
    Warning: _execute_list_table_query self::$query_parameters = array ( 'use_postmeta_view' => false, 'orderby' => 'post_parent', 'order' => 'ASC', 'detached' => false, 'debug' => 'console', 's' => '1828', 'mla_search_connector' => 'AND', 'mla_search_fields' => array ( 0 => 'title', 1 => 'content', ), 'sentence' => false, 'exact' => false, 'postmeta_key' => '_wp_attachment_image_alt', ) in ..wp-content/plugins/media-library-assistant/includes/class-mla-data.php on line 676
    
    Warning: _execute_list_table_query $results->request = 'SELECT SQL_CALC_FOUND_ROWS cms_posts.* FROM cms_posts WHERE 1=1 AND ( ( (cms_posts.post_title LIKE "%>|<1828%") OR (cms_posts.post_content LIKE "%>|<1828%")) OR ( cms_posts.post_parent IN ( select ID from cms_posts as b where b.<code>post_type</code> <> "attachment" and b.<code>post_title</code> like "%>|<1828%" ) ) ) AND cms_posts.post_type = "attachment" AND (cms_posts.post_status = "inherit" OR cms_posts.post_status = "private") ORDER BY cms_posts.post_date DESC LIMIT -200, 200' in ..wp-content/plugins/media-library-assistant/includes/class-mla-data.php on line 677
    
    Warning: _execute_list_table_query $results->post_count = 0 in ..wp-content/plugins/media-library-assistant/includes/class-mla-data.php on line 678
    
    Warning: _execute_list_table_query $results->found_posts = 0 in ..wp-content/plugins/media-library-assistant/includes/class-mla-data.php on line 679
  17. David Lingren
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks for running the test and posting the warning messages; they are very helpful.

    What they show is that the SQL statement used to query the database is different from the WordPress WP_Query parameters that MLA is specifying. For example, the "ORDER BY" clause is changed from post_parent to post_date, post_status = "private" has been added and the LIMIT clause has been added. Most important, the $search_clause that MLA inserts to perform the ID/Parent search is gone and has been replaced by the default WordPress search clause (including the ">|<" switch). That's why you get no results.

    It looks like some other plugin or software has gone back to the original 's' argument in the HTML $_REQUEST variables and built it's own SQL statement from that.

    I know we've had trouble with Role Scoper in the past. Can you tell me what plugins are active on your site so I can look for interference? Thanks!

  18. jorgeorpinel
    Member
    Posted 1 year ago #

    Yeah, there's a bunch of plugins on this site. Let me try disabling the ones that I think could relate to media and see if I can pinpoint the culprit :)

  19. jorgeorpinel
    Member
    Posted 1 year ago #

    Found it... Media Search was causing the conflict... Which is really funny since I was using it to provide the regular media library with the same functionality, to find items by parent. Ha. I guess I'll have to choose one or the other!

  20. David Lingren
    Member
    Plugin Author

    Posted 1 year ago #

    At last! Thanks for chasing this down such a long and winding road.

    I don't think you need Media Search anymore, but if you find something it does that MLA does not do, I will try to make MLA the only "searcher" you need. Let me know what else I can do to help.

  21. jorgeorpinel
    Member
    Posted 1 year ago #

    Yes. The choice is very obvious... MLA offers tons more functionalities. Thank you so much for all the work David!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic