名称: product_categorys 

功能:读取所有商品分类列表,多级菜单菜单自动格式化为树形结构

代码示例:

{if($product_categorys)}
<ul class="list-group margin-bottom-25 sidebar-menu">
	{loop $product_categorys $k1 $v1}
  <li class="list-group-item clearfix {if($v1['children'])}dropdown {if(array_key_exists($k1, $category_info['fatherTree']))}active{/if}{/if}">
  	<a href="{if($v1['children'])}javascript:void(0);{else}{$v1['category_url']}{/if}" class="{if($v1['children'])}collapsed{/if}">
  		<i class="fa fa-angle-right"></i> {$v1['cat_name']}
  		{if($v1['children'])}<i class="fa fa-angle-down"></i>{/if}
  	</a>
  	{if($v1['children'])}
  	<ul class="dropdown-menu" style="display:block;">
  	{loop $v1['children'] $k2 $v2}
  	<li class="list-group-item dropdown {if($v2['children'])}dropdown {if(array_key_exists($k2, $category_info['fatherTree']))}active{/if}{/if}">
    	<a href="{if($v2['children'])}javascript:void(0);{else}{$v2['category_url']}{/if}" class="">
    	<i class="fa fa-circle"></i> {$v2['cat_name']}
    	{if($v2['children'])}<i class="fa fa-angle-down"></i>{/if}
   		</a>
   		{if($v2['children'])}
      <ul class="dropdown-menu" style="display:{if(array_key_exists($v2['cat_id'], $category_info['fatherTree']))}block{else}none{/if};">
      	{loop $v2['children'] $k3 $v3}
        <li class="list-group-item dropdown clearfix {if(array_key_exists($k3, $category_info['fatherTree']))}active{/if}">
          <a href="{if($v3['children'])}javascript:void(0);{else}{$v3['category_url']}{/if}">
          	<i class="fa fa-circle"></i> {$v3['cat_name']}
          	{if($v3['children'])}<i class="fa fa-angle-down"></i>{/if}
          </a>
          {if($v3['children'])}
          <ul class="dropdown-menu">
          	{loop $v3['children'] $k4 $v4}
            <li><a href="{$v4['category_url']}"><i class="fa fa-circle"></i> {$v4['cat_name']}</a></li>
            {/loop}
          </ul>
          {/if}
        </li>
        {/loop}
      </ul>
      {/if}
      </li>
  	{/loop}
  	</ul>
  	{/if}
  </li>
  {/loop}
{/if}
数据格式打印: 

Array
(
    [1] => Array
        (
            [cat_id] => 1
            [category] => top_menu
            [parent_id] => 0
            [unique_id] => 女士
            [cat_name] => 女士
            [title] => 女士服装包鞋帽
            [keywords] => 女士,女装,女鞋,女包,女帽
            [description] => 
            [content] => 
            [sort] => 1
            [category_url] => /女士/p1-products.html
            [children] => Array
                (
                    [2] => Array
                        (
                            [cat_id] => 2
                            [category] => top_menu
                            [parent_id] => 1
                            [unique_id] => 女装
                            [cat_name] => 女装
                            [title] => 女装
                            [keywords] => 女装
                            [description] => 女装
                            [content] => 
                            [sort] => 0
                            [category_url] => /女装/p1-products.html
                            [children] => Array
                                (
                                    [13] => Array
                                        (
                                            [cat_id] => 13
                                            [category] => top_menu
                                            [parent_id] => 2
                                            [unique_id] => 女士T恤
                                            [cat_name] => 女士T恤
                                            [title] => 女士T恤
                                            [keywords] => 女士T恤
                                            [description] => 女士T恤
                                            [content] => 
                                            [sort] => 3
                                            [category_url] => /女士T恤/p1-products.html
                                        )

                                    [14] => Array
                                        (
                                            [cat_id] => 14
                                            [category] => top_menu
                                            [parent_id] => 2
                                            [unique_id] => 女士针织衫
                                            [cat_name] => 女士针织衫
                                            [title] => 女士针织衫
                                            [keywords] => 女士针织衫
                                            [description] => 女士针织衫
                                            [content] => 
                                            [sort] => 3
                                            [category_url] => /女士针织衫/p1-products.html
                                        )
                                )
                        )
                )
        )

    [42] => Array
        (
            [cat_id] => 42
            [category] => top_menu
            [parent_id] => 0
            [unique_id] => 儿童
            [cat_name] => 儿童
            [title] => 儿童
            [keywords] => 儿童
            [description] => 
            [content] => 
            [sort] => 0
            [category_url] => /儿童/p1-products.html
        )
)
 模板示例截图: