We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Need Clarification on 3 edit_entries Hooks for Filtering by Custom Field

Development and Programming

Ryan M.'s avatar
Ryan M.
1,511 posts
16 years ago
Ryan M.'s avatar Ryan M.

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:

  1. edit_entries_search_fields
  2. edit_entries_search_tables
  3. edit_entries_search_where

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

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
16 years ago
Sue Crocker's avatar Sue Crocker

Hi, Ryan. I’m going to move this to the Extensions forum for additional community support.

       
Ryan M.'s avatar
Ryan M.
1,511 posts
16 years ago
Ryan M.'s avatar Ryan M.

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!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.