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.
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.
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]
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?
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.