-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Nathan Pitman
committed
Mar 26, 2015
1 parent
02c2c13
commit 03e6663
Showing
2 changed files
with
29 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,8 @@ | |
* Categories Field Fieldtype | ||
* | ||
* @package nf_categories_field | ||
* @author Nathan Pitman <[email protected]> | ||
* @copyright Copyright (c) 2014, Nine Four Ltd | ||
* @author Nathan Pitman, <[email protected]> | ||
* @copyright Copyright (c) 2015, NAthan Pitman | ||
*/ | ||
class Nf_categories_field_ft extends EE_Fieldtype { | ||
|
||
|
@@ -731,27 +731,48 @@ function replace_tag_catchall($data, $params = array(), $tagdata = FALSE, $modif | |
* @return Array Array of data read for the parser containing | ||
* category IDs, names, and url_titles | ||
*/ | ||
private function _get_category_data($cat_ids, $limit=NULL, $group_id=NULL) | ||
private function _get_category_data($cat_ids, $limit=NULL, $group_id=NULL, $with_custom_fields=TRUE) | ||
{ | ||
// Pull in category data and map it | ||
ee()->load->model('category_model'); | ||
|
||
// Get the standard field data (including the custom field data) | ||
ee()->db->from('categories c'); | ||
ee()->db->join('category_field_data cfd', 'cfd.cat_id=c.cat_id', 'left'); | ||
ee()->db->limit($limit); | ||
$category_query = ee()->db->where_in('cat_id', $cat_ids) | ||
->get('categories') | ||
->result_array(); | ||
ee()->db->where_in('c.cat_id', $cat_ids); | ||
$category_query = ee()->db->get()->result_array(); | ||
|
||
// Get the custom field names | ||
ee()->db->from('category_fields cf'); | ||
if ($group_id) { | ||
ee()->db->where('cf.group_id', $group_id); | ||
} | ||
$custom_fields_query = ee()->db->get()->result_array(); | ||
|
||
// Create the array for parsing | ||
$parse = array(); | ||
$i = 0; | ||
foreach ($category_query as $category_row) | ||
{ | ||
$parse[] = array( | ||
|
||
// Standard category fields | ||
$parse[$i] = array( | ||
'category_id' => $category_row['cat_id'], | ||
'category_parent_id' => $category_row['parent_id'], | ||
'category_name' => $category_row['cat_name'], | ||
'category_url_title' => $category_row['cat_url_title'], | ||
'category_description' => $category_row['cat_description'], | ||
'category_image' => $category_row['cat_image'] | ||
); | ||
|
||
// Add custom fields | ||
foreach($custom_fields_query AS $custom_field) { | ||
$custom_field_name = "field_id_".$custom_field['field_id']; | ||
$parse[$i][$custom_field['field_name']] = $category_row[$custom_field_name]; | ||
} | ||
|
||
$i++; | ||
} | ||
|
||
return $parse; | ||
|