Adding An Extra Filter to the Edit Page
Posted: 25 September 2007 08:20 PM   [ Ignore ]  
Lab Assistant
RankRank
Total Posts:  121
Joined  09-18-2007

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.

Profile
 
 
Posted: 26 September 2007 07:16 AM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23538
Joined  05-20-2002

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.

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 01 October 2007 06:37 PM   [ Ignore ]   [ # 2 ]  
Lab Assistant
RankRank
Total Posts:  121
Joined  09-18-2007

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):

$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' ";
        
}
        
    }

Profile
 
 
Posted: 02 October 2007 12:32 AM   [ Ignore ]   [ # 3 ]  
Lab Assistant
RankRank
Total Posts:  121
Joined  09-18-2007

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?

Profile
 
 
Posted: 02 October 2007 08:13 PM   [ Ignore ]   [ # 4 ]  
Lab Assistant
RankRank
Total Posts:  121
Joined  09-18-2007

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

code is attached.

File Attachments
ext.filter_by_rank.zip  (File Size: 2KB - Downloads: 161)
Profile
 
 
Posted: 08 February 2008 02:35 AM   [ Ignore ]   [ # 5 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  135
Joined  05-25-2002

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

 Signature 

Caleydon Media

+ CM Strange URL Interpreter
+ CM Textarea Resizer
+ CM Template Editor (EditArea)

Profile
 
 
Posted: 10 February 2008 06:21 PM   [ Ignore ]   [ # 6 ]  
Lab Assistant
RankRank
Total Posts:  121
Joined  09-18-2007

lang file attached (:

File Attachments
lang.filter_by_rank.zip  (File Size: 1KB - Downloads: 95)
Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 65027 Total Logged-in Users: 43
Total Topics: 82116 Total Anonymous Users: 15
Total Replies: 441312 Total Guests: 186
Total Posts: 523428    
Members ( View Memberlist )