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

Adding An Extra Filter to the Edit Page

Development and Programming

hereward's avatar
hereward
91 posts
17 years ago
hereward's avatar hereward

I have created a weblog field (within a custom field group) called “rank” and i want to add a new drop down on the Edit control panel called “Filter by Rank”.

Do i need to write an extension to do this?

I have already installed one extension called “Filter By Author” and was planning to hack this in order to create my new extension, however I am finding this more difficult than anticipated due to the SQL and my lack of familiarity with the database structure.

If you can point me in the right direction in order to achieve this goal that would be much appreciated.

       
Robin Sowell's avatar
Robin Sowell
13,160 posts
17 years ago
Robin Sowell's avatar Robin Sowell

Yep- an extension would be the way to go, and if you’ve got one that does something similar, adding on to that is probably the easiest way to do it. But- I’m not familiar with the author filter, so I’m not much help on where to start. I’m going to shift this one down to the ‘extensions’ forum- and you might ask the author of the extension to see if they have any pointers.

I can say for certain that filtering on a custom field will be a bit trickier- you’ll need to hit the exp_member_data table, which isn’t hit on the edit tab normally. The author one would just be pulling from the member table- which is normally queries as author name is displayed.

       
hereward's avatar
hereward
91 posts
17 years ago
hereward's avatar hereward

Is thre anyone who can give me a few pointers on this? The area I am having trouble with is working out how to create the correct SQL using the API.

I have tried the following (without success):

<pre><code> $DB->query($DB->insert_string(‘exp_extensions’, array( ‘extension_id’ => ”, ‘class’ => “Filter_by_rank”, ‘method’ => “exp_weblog_data_func”, ‘hook’ => “edit_entries_search_tables”, ‘settings’ => “”, ‘priority’ => 1, ‘version’ => $this->version, ‘enabled’ => “y” ) ) );

function exp_weblog_data_func() 
{
    global $IN;

    $rank = $IN->GBL('rank', 'GP');

    if ($rank != '' && is_numeric($rank))
    {
        return " INNER JOIN exp_weblog_data ON exp_weblog_data.site_id=exp_weblog_titles.site_id AND exp_weblog_data.field_id_5 = '$rank' ";
    }

}[/code]
       
hereward's avatar
hereward
91 posts
17 years ago
hereward's avatar hereward

OK, I am going to suggest a solution to myself. I think that I am going to need to create a new table, call it “exp_weblog_titles_meta” - and I am going to store the “rank” in this new table, linking on entry_id - that will allow me to use the SQL hooks.

I was previously thinking i could simply create a custom field and then store the rank in “exp_weblog_data” - but this is not looking too good.

Any comments?

       
hereward's avatar
hereward
91 posts
17 years ago
hereward's avatar hereward

OK I have resolved this. This solution can apply to any situation where you want to filter on a custom field.

code is attached.

       
Gabriel's avatar
Gabriel
130 posts
17 years ago
Gabriel's avatar Gabriel

hereward: the language file missing in the extension above. Could you fix it? Thanks.

       
hereward's avatar
hereward
91 posts
17 years ago
hereward's avatar hereward

lang file attached (:

       

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.