循环文件夹及文件夹下文章


列出栏目名称和连接并高亮当前栏目:
注意先把kk_folder_id当前的分类的id存到变量kk里,然后在循环体内用这个变量,直接使用的话做判断不好使。

<cms:set kk = k_folder_id />
<cms:folders masterpage='' depth="1" orderby='weight' order='asc'>
   <li>
   <a href="#"><cms:show k_folder_title /> <span uk-nav-parent-icon></span></a>
   <ul>
       <cms:folders masterpage="" hierarchical="1" depth="2" childof=k_folder_name orderby='weight' order='asc'>
       <li <cms:if kk = "<cms:show k_folder_id />">class="active"</cms:if>><a href="<cms:show k_folder_link />"><cms:show k_folder_title /></a></li>
       </cms:folders>
   </ul>
   </li>
</cms:folders>

以下是1级循环,循环列出栏目名称及栏目下的文章

<cms:folders paginate='1' hierarchical='1' startcount='0' orderby='weight' order='asc'>
    <h2 class="serises_folder"><span><cms:show k_folder_title /></span></h2>
    <div><a href="<cms:show k_folder_link />"><img src="<cms:show k_folder_image />"></a></div>
    <div uk-grid class="uk-child-width-1-4@m uk-child-width-1-2 uk-grid-small product_list">
        <cms:pages masterpage='product.php' folder=k_folder_name paginate='1' limit='12' orderby='weight' order='asc'>
        <div>
            <figure class="uk-position-relative">
               <a href="<cms:show k_page_link />"><img src="<cms:show thumb_image />" alt="<cms:show k_page_title />" title="<cms:show k_page_title />"></a>
               <figcaption class="uk-position-bottom-center"><cms:show xinghao /></figcaption>
            </figure>
         </div>
         <cms:if k_paginated_bottom>
         <div class="uk-width-1-1 pagelist">
            <cms:paginator />
         </div>
         </cms:if>
         </cms:pages>
    </div>
</cms:folders>

如果遇到有2级栏目加栏目下的文章,可以使用以下代码:

<cms:folders masterpage="teacher.php" depth="1" orderby='weight' order='asc'>
   <h3 style="margin: 20px;"><span style="display: inline-block; padding: 3px 10px; color: #fff; background-color: #4c97d9;"><cms:show k_folder_title /></span></h3>
   <cms:folders masterpage="teacher.php" hierarchical="1" depth="2" childof=k_folder_name orderby='weight' order='asc'>
      <div class="uk-card uk-margin-top">
         <div uk-grid class="uk-grid-small">
            <div class="uk-width-1-5">
               <h5><cms:show k_folder_title /></h5>
            </div>
            <div class="uk-width-4-5">
              <ul uk-grid class="uk-child-width-1-4">
                 <cms:pages masterpage="teacher.php" orderby='weight' order='asc' folder=k_folder_name>
                 <li>
                    <figure>
                       <div class="img_thumb"><img src="<cms:show _thumb_image />" alt="<cms:show k_page_title />"></div>
                       <figcaption><cms:show k_page_title /></figcaption>
                    </figure>
                 </li>
                 </cms:pages>
              </ul>
            </div>
          </div>
      </div>
   </cms:folders>
</cms:folders>