I have a thread entitled Filter By Custom Field Dropdown in the Control Panel Edit Entries List where I outline how I’ve failed to do just that attempting to use three hooks:
I decided to start a thread here because, although the thread is about Extension development, it’s becoming more about those particular hooks and what they do-or don’t do. (EDIT: This has since been moved right back to the extensions forum - ryan) As I stated in the other thread, I’m perplexed why querying for and sorting on a custom field seems so hard to accomplish, particularly when it seems like there are hooks made for this very purpose. I admit I could be using these things incorrectly, but existing examples and more thorough explanations about what the hooks actually allow you to do are not there in the docs.
Could someone post an example of how you might use the three hooks above (or any combination of them that would actually work) where you query for a custom field (from the exp_weblog_data table) and get results that paginate correctly? I’m assuming I need the hooks for these reasons:
1. edit_entries_search_fields Get the field I want (exp_weblog_data.field_id_23)
2. edit_entries_search_tables Grab from the table I need (LEFT JOIN exp_weblog_data ON exp_weblog_data.entry_id=exp_weblog_titles.entry_id)
3. edit_entries_search_where Add the search condition (AND exp_weblog_data.field_id_23 = ‘” . $storelocation . “’ )
Based on all the things posted in the other thread, I simply cannot get this to work. That LEFT JOIN never seems to show.
I’d even appreciate any advice as to which one of these two versions of the “same” thing are correct?
Using the edit_entries_search_where hook, Version 1:
function edit_entries_search_where()
{
global $EXT, $IN;
$out = ($EXT->last_call !== FALSE) ? $EXT->last_call : '';
if(isset($_POST['storelocation']) === TRUE && empty($_POST['storelocation']) === FALSE)
{
$out .= " AND exp_weblog_data.field_id_23 = '" . $_POST['storelocation'] . "' ";
}
return $out;
}
Using the edit_entries_search_where hook, Version 2:
function edit_entries_search_where()
{
global $IN;
$storelocation = $IN->GBL('storelocation', 'GP');
if($storelocation != '')
{
return " AND exp_weblog_data.field_id_23 = '" . $storelocation . "' ";
}
}
One of those checks for last call, one does not. I’ve tried both kinds. Is one of those technically correct? Thanks in advance for any thoughts on this.
Moved to Extensions by Moderator
Well, I was trying to get more explanation about the hooks themselves (which is a core EE thing) rather than the extension. Can I put in a Feature Request for an example of how to use a particular hook, to be posted directly on the hook’s page in the EE docs? Hello! Hello! Hello!
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.