It looks like you're new here. If you want to get involved, click one of these buttons!
foreach($categories as $category)
{
$cat_id = $category['id'];
$return[$cat_id] = array('id' => $cat_id, 'label' => $category['title'], 'parent_id' => 0, 'location' => fuel_url('ads/categories/edit/'.$cat_id));
}
foreach($sub_categories as $val)
{
$attributes = ($val['published'] == 'no') ? array('class' => 'unpublished', 'title' => 'unpublished') : NULL;
$return["s_".$val['id']] = array('label' => $val['title'], 'parent_id' => $val['id_ads_categories'], 'location' => fuel_url('ads/subcategories/edit/'.$val['id']), 'attributes' => $attributes);
}
$CI =& get_instance();
$CI->load->module_model(ADS_FOLDER, 'ads_categories_model');
$CI->load->module_model(ADS_FOLDER, 'ads_subcategories_model');
$CI->load->module_model(ADS_FOLDER, 'ads_products_model');
$CI->load->helper('array');
$return = array();
$categories = $CI->ads_categories_model->find_all(array(), 'title asc');
$sub_categories = $CI->ads_subcategories_model->find_all('', 'title asc');
$products = $CI->ads_products_model->find_all('', 'product_name asc');
// CATEGORY TREE LEVELS //
foreach($categories as $category)
{
$cat_id = $category['id'];
$return[$category['id']] = array('id' => $category['id'], 'label' => $category['title'], 'parent_id' => 0, 'location' => fuel_url('ads/categories/edit/'.$category['id']));
}
// SUB-CATEGORY TREE LEVELS //
foreach($sub_categories as $val)
{
$attributes = ($val['published'] == 'no') ? array('class' => 'unpublished', 'title' => 'unpublished') : NULL;
$return["s_".$val['id']] = array('label' => $val['title'], 'parent_id' => $val['id_ads_categories'], 'location' => fuel_url('ads/subcategories/edit/'.$val['id']), 'attributes' => $attributes);
}
// PRODUCT TREE LEVELS //
foreach($products as $prod)
{
$attributes = ($prod['published'] == 'no') ? array('class' => 'unpublished', 'product_name' => 'unpublished') : NULL;
$return["p_".$prod['id']] = array('label' => $prod['product_name'], 'parent_id' => $prod['id_ads_subcategories'], 'location' => fuel_url('ads/products/edit/'.$prod['id']), 'attributes' => $attributes);
}
Comments
foreach($products as $prod) { $attributes = ($prod['published'] == 'no') ? array('class' => 'unpublished', 'product_name' => 'unpublished') : NULL; $return["p_".$prod['id']] = array('id' => "p_".$prod['id'], 'label' => $prod['product_name'], 'parent_id' => "s_".$prod['id_ads_subcategories'], 'location' => fuel_url('ads/products/edit/'.$prod['id']), 'attributes' => $attributes); }