// First code for this was sending 15 queries for 15 fetched entries,
// this is now limited to just one query per fetched articles group
- $search_ids = array(); // An array to hold all ids of the entry we want to fetch.
- $assoc_ids = array(); // A temporary key association container to not have to loop through the return array once again.
+ serendipity_fetchEntryData($ret);
+ }
- foreach($ret AS $i => $entry) {
- $search_ids[] = $entry['id'];
- $ret[$i]['categories'] = array(); // make sure every article gets its category association
- $assoc_ids[$entry['id']] = $i; // store temporary reference
- }
+ return $ret;
+}
- serendipity_plugin_api::hook_event('frontend_entryproperties', $ret, $assoc_ids);
+/**
+ * Attach special entry data to entry
+ */
+function serendipity_fetchEntryData(&$ret) {
+ global $serendipity;
- $query = "SELECT
- ec.entryid,
- c.categoryid,
- c.category_name,
- c.category_description,
- c.category_icon,
- c.parentid
- FROM {$serendipity['dbPrefix']}category AS c
- LEFT JOIN {$serendipity['dbPrefix']}entrycat AS ec
- ON ec.categoryid = c.categoryid
- WHERE " . serendipity_db_in_sql('ec.entryid', $search_ids);
+ $search_ids = array(); // An array to hold all ids of the entry we want to fetch.
+ $assoc_ids = array(); // A temporary key association container to not have to loop through the return array once again.
+
+ foreach($ret AS $i => $entry) {
+ $search_ids[] = $entry['id'];
+ $ret[$i]['categories'] = array(); // make sure every article gets its category association
+ $assoc_ids[$entry['id']] = $i; // store temporary reference
+ }
- $search_ret = serendipity_db_query($query, false, 'assoc');
+ serendipity_plugin_api::hook_event('frontend_entryproperties', $ret, $assoc_ids);
- if (is_array($search_ret)) {
- foreach($search_ret AS $i => $entry) {
- $ret[$assoc_ids[$entry['entryid']]]['categories'][] = $entry;
- }
+ $query = "SELECT
+ ec.entryid,
+ c.categoryid,
+ c.category_name,
+ c.category_description,
+ c.category_icon,
+ c.parentid
+ FROM {$serendipity['dbPrefix']}category AS c
+ LEFT JOIN {$serendipity['dbPrefix']}entrycat AS ec
+ ON ec.categoryid = c.categoryid
+ WHERE " . serendipity_db_in_sql('ec.entryid', $search_ids);
+
+ $search_ret = serendipity_db_query($query, false, 'assoc');
+
+ if (is_array($search_ret)) {
+ foreach($search_ret AS $i => $entry) {
+ $ret[$assoc_ids[$entry['entryid']]]['categories'][] = $entry;
}
}
-
- return $ret;
}
/**
$limit";
$search = serendipity_db_query($querystring);
+
+ if (is_array($search)) {
+ serendipity_fetchEntryData($search);
+ }
+
return $search;
}