Esempio n. 1
0
function dispayThumbCate($categories, $level = 0, $show = 'no', $link = 'categories/')
{
    if (!is_array($categories) or empty($categories)) {
        return '';
    }
    $html = '';
    if (count($categories)) {
        $cate_id = array();
        foreach ($categories as $category) {
            if ($category->image == '') {
                $category->image = base_url('assets/images/default.png');
            } else {
                $category->image = base_url($category->image);
            }
            if ($link . $category->id . '-' . $category->slug == uri_string()) {
                $style = 'style="background: #f1f1f1; border: 1px solid #428bca;"';
            } else {
                $style = '';
            }
            if ($show == 'yes') {
                if ($level == 0) {
                    $html .= '<li><a href="' . site_url() . $link . $category->id . '-' . $category->slug . '"><img ' . $style . ' class="img-thumbnail" src="' . $category->image . '" alt="' . $category->title . '"/></a></li>';
                } else {
                    if ($category->id == $level) {
                        $html .= '<li><a href="' . site_url() . $link . $category->id . '-' . $category->slug . '"><img ' . $style . ' class="img-thumbnail" src="' . $category->image . '" alt="' . $category->title . '"/></a></li>';
                    } else {
                        $html .= dispayThumbCate($category->subcategories, $level, $show, $link);
                    }
                }
            } else {
                if ($level == 0) {
                    $html .= '<li><a href="' . site_url() . $link . $category->id . '-' . $category->slug . '"><img ' . $style . ' class="img-thumbnail" src="' . $category->image . '" alt="' . $category->title . '"/></a></li>';
                    if (count($category->subcategories) > 0) {
                        $html .= dispayThumbCate($category->subcategories, $level, $show, $link);
                    }
                } else {
                    if ($category->id == $level || $category->parent_id == $level || in_array($category->parent_id, $cate_id)) {
                        $cate_id[] = $category->id;
                        $html .= '<li><a href="' . site_url() . $link . $category->id . '-' . $category->slug . '"><img ' . $style . ' class="img-thumbnail" src="' . $category->image . '" alt="' . $category->title . '"/></a></li>';
                        if (count($category->subcategories) > 0) {
                            $html .= dispayThumbCate($category->subcategories, $level, $show, $link);
                        }
                    } else {
                        $html .= dispayThumbCate($category->subcategories, $level, $show, $link);
                    }
                }
            }
        }
    }
    return $html;
}
Esempio n. 2
0
     echo '<ul class="nav nav-list list-categories">';
     $categories = dispayListCate($categories, $cate_id);
     $categories = explode('<li>', $categories);
     $i = 0;
     foreach ($categories as $category) {
         if ($show_number < $i) {
             break;
         }
         if ($category != '') {
             echo '<li>' . $category . '</li>';
         }
         $i++;
     }
 } else {
     echo '<ul class="thumb-categories">';
     $categories = dispayThumbCate($categories, $cate_id, $show_level);
     $categories = explode('<li>', $categories);
     $i = 0;
     foreach ($categories as $category) {
         if ($show_number < $i) {
             break;
         }
         if ($category != '') {
             echo '<li>' . $category . '</li>';
         }
         $i++;
     }
 }
 echo '</ul>';
 echo '</div>';
 ?>
Esempio n. 3
0
     echo '<ul class="nav nav-list list-categories">';
     $categories = dispayListCate($categories, $cate_id, 'idea/');
     $categories = explode('<li>', $categories);
     $i = 0;
     foreach ($categories as $category) {
         if ($show_number < $i) {
             break;
         }
         if ($category != '') {
             echo '<li>' . $category . '</li>';
         }
         $i++;
     }
 } else {
     echo '<ul class="thumb-categories">';
     $categories = dispayThumbCate($categories, $cate_id, $show_level, 'idea/');
     $categories = explode('<li>', $categories);
     $i = 0;
     foreach ($categories as $category) {
         if ($show_number < $i) {
             break;
         }
         if ($category != '') {
             echo '<li>' . $category . '</li>';
         }
         $i++;
     }
 }
 echo '</ul>';
 echo '</div>';
 ?>