Multiple catogories in "Recent Entries" *SOLVED*
Multiple catogories in "Recent Entries" *SOLVED*
Is is possible to modify the plugin recent entries so one could show new entries from 2 categories?
As it is now, one can show from one category or all.
As it is now, one can show from one category or all.
Last edited by jojje on Tue Jan 10, 2006 4:45 pm, edited 1 time in total.
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Multiple catogories in "Recent Entries"
That would be a bit harder to implement within the configuration screen.
But it would be very easy by adjusting the PHP code of the plugin and creating your own custom plugin for that.
Best regards,
Garvin
But it would be very easy by adjusting the PHP code of the plugin and creating your own custom plugin for that.
Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
ok, watched the code and I don´t really know what to edit. The plugin show_entries looks a lot easier to modiefy for me, it already has a function to add selected categories.
Or perhaps someone can give me a hint?
This is the code for selecting category:
or should one make the adjustment here:
Or perhaps someone can give me a hint?
This is the code for selecting category:
Code: Select all
case 'category':
$cats = serendipity_fetchCategories($serendipity['authorid']);
if (!is_array($cats)) {
return false;
}
$catlist = serendipity_generateCategoryList($cats, array(0), 4);
$tmp_select_cats = explode('@@@', $catlist);
if (!is_array($tmp_select_cats)) {
return false;
}
$select_cats = array();
$select_cats['none'] = ALL_CATEGORIES;
foreach($tmp_select_cats as $cidx => $tmp_select_cat) {
$select_cat = explode('|||', $tmp_select_cat);
if (!empty($select_cat[0]) && !empty($select_cat[1])) {
$select_cats[$select_cat[0]] = $select_cat[1];
}
}
$propbag->add('type', 'select');
$propbag->add('select_values', $select_cats);
$propbag->add('name', CATEGORY);
$propbag->add('description', CATEGORIES_TO_FETCH);
$propbag->add('default', 'none');
break;Code: Select all
function generate_content(&$title) {
global $serendipity;
$number = $this->get_config('number');
$dateformat = $this->get_config('dateformat');
$category = $this->get_config('category', 'none');
$title = $this->get_config('title', $this->title);
$number_from_sw = $this->get_config('number_from');
$sql_join = '';
$sql_where = '';
if ($category != 'none' && is_numeric($category)) {
$sql_join = 'LEFT OUTER JOIN ' . $serendipity['dbPrefix'] . 'entrycat AS ec ON id = ec.entryid
LEFT OUTER JOIN ' . $serendipity['dbPrefix'] . 'category AS c ON ec.categoryid = c.categoryid';
$sql_where = ' AND (c.category_left BETWEEN ' . implode(' AND ', serendipity_fetchCategoryRange($category)) . ')';
}-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Serendipity doesn't havge a "multiselect" option type, which is why the implementation would be so difficult. You would need another GUI element to represent how to treat a multi selection, or immitate the solution other plugins have for multi-selects...
So, yes. The place you need to look at is the lower portion of the code.
Let's say you submit "13;15;18" as $category (by making the select dropdown an input field).
Then you need to modify the code below to use multiuple $categories within the "BETWEEN" statement, by using foreach loops and concatenating the SQL.
Regards,
garvin
So, yes. The place you need to look at is the lower portion of the code.
Let's say you submit "13;15;18" as $category (by making the select dropdown an input field).
Then you need to modify the code below to use multiuple $categories within the "BETWEEN" statement, by using foreach loops and concatenating the SQL.
Code: Select all
if ($category != 'none') {
$categories = explode(';', $category);
$sql_join = 'LEFT OUTER JOIN ' . $serendipity['dbPrefix'] . 'entrycat AS ec ON id = ec.entryid
LEFT OUTER JOIN ' . $serendipity['dbPrefix'] . 'category AS c ON ec.categoryid = c.categoryid';
$sql_where = ' AND (c.category_left BETWEEN ' . implode(' AND ', serendipity_fetchCategoryRange($category)) . ')';
}garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
I'll work on that a bit, I might come up with a solution soon.
Regards,
Garvin
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Please have a look at this Patch I just committed to SVN:
http://svn.berlios.de/viewcvs/serendipi ... 2&view=rev
Regards,
Garvin
http://svn.berlios.de/viewcvs/serendipi ... 2&view=rev
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
AAARRGH! I spent DAYS coding a multiselect for the newscategory plugin, and now you've gone and made it a standard feature!
Sometimes it hurts when good stuff happens.
Great job, Garvin. I only wish I had thought of it.
Incidentally, I'm sorry I'm so slow lately. I'm preparing for a big test event at work. I'll still be here whenever I can, but it's definitely taking a back seat to my primary source of income.
Sometimes it hurts when good stuff happens.
Great job, Garvin. I only wish I had thought of it.
Incidentally, I'm sorry I'm so slow lately. I'm preparing for a big test event at work. I'll still be here whenever I can, but it's definitely taking a back seat to my primary source of income.
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Hey judebert! Sorry that I didn't help you out earlier with that 
I just abstracted the plugin configuration a bit more (in 1.0 alpha) so that some other functions will be usable by plugins in the future.
Good luck with your big test event!
Best regards,
Garvin
I just abstracted the plugin configuration a bit more (in 1.0 alpha) so that some other functions will be usable by plugins in the future.
Good luck with your big test event!
Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Hi Judebert!
Regards,
Garvin
That's what I was thinking of, too. Actually this was my main reason to do abstraction. *g*I'm thinking abstracting those functions will be good for the theme configurator, too...
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/