Exemplu:
Categoria 1 - subcategoria 1, 2,3 ... etc
Categoria 2
Categoria 3 - subcategoria 1,2,3 ... etc...
Atunci cand sunt cu mouse-ul deasupra categoriei 1 imi apare ultimele 2 postari din aceea categorie plus lista de subcategorii, atunci cand sunt cu mouse-ul deasupra categoriei 2 nu imi apare nimic.
Ceea ce doresc sa fac si nu reusesc este ca atunci cand sunt cu mouse-ul deasupra categoriei 2 (acolo unde nu exista subcategorii) sa imi apara ultimele 2 sau 4 postari din categorie.
Codul este urmatorul:
Cod: Selectaţi tot
public function get_navigation_menu()
{
$childCategories=array();
$out='<ul class="discussion-nav-categories">';
$out.='<li id="the-home-icon"><a title="Discutii" href="'.site_url('discutii').'"><img src="/app/templates/site_default/images/casuta-header.png" style="padding-top:1px;"/></a></li>';
$categories=$this->get_all_parent();
foreach($categories AS $category)
{
$childCategories[$category->category_id] = $this->get_all_child($category->category_id);
if(empty($childCategories[$category->category_id]))
$out.='<li class="parent-category parent-category-id-'.$category->category_id.'"><a title="'.$category->name.'" href="'.$this->landing_page_url($category->url).'">'.$category->name.'</a></li>';
else
$out.='<li class="parent-category parent-category-id-'.$category->category_id.'"><a title="'.$category->name.'" href="javascript:;">'.$category->name.'</a></li>';
}
$out.='</ul>';
$columns = 4;
$perColumn = 7;
$out.= '<div class="subcategories-columns">';
foreach($categories AS $category)
{
if(empty($childCategories[$category->category_id]))
continue;
$child = $childCategories[$category->category_id];
$out.='<div class="subcategory-column child-for-category-id-'.$category->category_id.'" style="display:none;">';
$count=count($child);
$subcategoryColumns = ceil($count / $perColumn);
if($subcategoryColumns > $columns)
$subcategoryColumns=$columns;
$subcategoriesArray=array();
foreach($child AS $cat)
{
$subcategoriesArray[] = $cat->category_id;
}
shuffle($subcategoriesArray);
$postsToShow = $columns - $subcategoryColumns;
$posts = $this->get_category_posts_in($subcategoriesArray, $postsToShow);
foreach($posts AS $post)
{
$out.='<div class="column">';
$out.='<div class="post">';
$out.='<div class="image"><a title="'.$post->title.'" href="'.site_url('discutii/'.$post->category_url.'/'.$post->post_id.'-'.$post->url).'">'.$this->post->post_image_video($post, array('data-width'=>200,'data-height'=>150)).'</a></div>';
$out.='<div class="title"><a title="'.$post->title.'" href="'.site_url('discutii/'.$post->category_url.'/'.$post->post_id.'-'.$post->url).'">'.$post->title.'</a></div>';
$out.='</div>';
$out.='</div>';
}
$out.='<div class="column">';
$out.='<div class="heading">Categorii:</div>';
$out.='<ul class="subcategories">';
$i=0;
foreach($child AS $cat)
{
++$i;
$out.='<li><a title="'.$cat->name.'" href="'.site_url('discutii/'.$cat->url).'">'.$cat->name.'</a></li>';
if($i % $perColumn == 0 && $i < $count)
$out.='</ul></div> <div class="column"><div class="heading"> </div><ul class="subcategories">';
}
$out.='</ul>';
$out.='</div>';
$out.='</div>';
}
$out.= '</div></div>';
return $out;
}