[eluser]diasansley[/eluser]
hey have a look at the code i have tried to implement categories view like a mac folder view.
attachin the screen shot as well.
no that works but only when i click on a small arrow that i have put!
I want the submenu to appear when i click on the category itself
here is my controller
Code:
class Categories extends WC_Controller
{
var $count;
function __construct()
{
parent::__construct();
}
/**
* redirects to paper list view
*/
function index()
{
$this-> content['title'] = "categories";
$brands = $this->m_brands->selectAllOrderBy('name','ASC');
$products = $this->m_products->selectAllOrderBy('name','ASC');
$entries = $this->m_entries->selectAllOrderBy('name','ASC');
$center_papers = $this->m_center_papers->selectAllOrderBy('id','DESC');
$this->content['content'] = $this->_renderFrontendOutput('home/_front_image_box.php',array('error' =>''));
$this->content['content'] .= $this->_renderFrontendOutput('home/_front_entries_search_box.php', array('entries'=>$entries,'brands'=>$brands,'products'=>$products));
$category_list = $this->get_categories_list();
$this->content['content'] .= $this->_renderFrontendOutput('categories/_show_categories.php',array('category_list'=>$category_list));
$this->renderTemplate();
}
function get_categories_list()
{
$categories = $this->m_categories->getAllCategory();
$max_id = $this->m_categories->getMaxId();
$max_id=$max_id[0]['max_id'];
$category_list = '';
foreach($categories as $category)
{
$level = 0;
$count = $this->m_category_to_category->hasChild($category['id']);
if($count[0]['cnt']>0)
{
$liclass = 'sub_category_bg';
}
else
{
$liclass = 'sub_category_bg2';
}
$category_list .= '<li class="'.$liclass.'" id="level_'.$level.'id_'.$category['id'].'"><a href="'.base_url().'entries/showAllEntries/category/'.$category['id'].'">'.$category['name'].'</a>';
$count = $this->m_category_to_category->hasChild($category['id']);
if($count[0]['cnt']>0)
{
$level++;
$category_list .='<a class="sub_category_link" href="#"><img src="'.base_url().'img/shared/bullet-icon.png" alt="" title="" /></a>';
}
$category_list .='</li>';
}
return $category_list;
}
function sub_categories($level,$id,$parent_id){
$max_id = $this->m_categories->getMaxId();
$max_id=$max_id[0]['max_id'];
$subcategories = $this->m_category_to_category->getChild($id);
$category_list ='';
//$category_list ='<ul>';
foreach($subcategories as $category)
{
$sub_level = $level;
$count = $this->m_category_to_category->hasChild($category['id']);
if($count[0]['cnt']>0)
{
$liclass = 'sub_category_bg';
}
else
{
$liclass = 'sub_category_bg2';
}
$category_list .= '<li class="'.$liclass.'" id="level_'.$sub_level.'_id_'.$category['id'].'"><a href="'.base_url().'entries/showAllEntries/category/'.$category['id'].'">'.$category['name'].'</a>';
if($count[0]['cnt']>0)
{
$sub_level++;
$category_list .='<a class="sub_category_link" href="#"><img src="'.base_url().'img/shared/bullet-icon.png" alt="" title="" /></a>';
}
$category_list .='</li>';
}
//$category_list .='</ul>';
$category_list .=$this->get_entries_for_categories($id);
echo $category_list;
}
/**
* function to get entries for categories
*/
function get_entries_for_categories($id)
{
$entries = $this->m_entry_to_category->getAllEntriesForCategory($id);
$entry_list = '';
if(!empty($entries)){
foreach($entries as $entry)
{
$entry_list.= '<li class="sub_category_bg3" ><a href="'.base_url().'entries/showEntryDetail/'.$entry['id'].'">'.$entry['name'].'</a>';
$entry_list.= "</li>";
}
}
return $entry_list;
}
}
/* End of file Categories.php */
/* Location: ./system/application/controllers/Categories.php */
?>