게시물 순번을 1-2-3순으로 출력하고, 1위부터 3위까지는 다른 모양으로 출력하게 해주고,

1차 카테고리에 공지사항이 있을 경우, 2차 카테고리에 있을 경우 이런 조합을 고려해서 다시 짜봤습니다. ㅠㅠ

 

<div class="no">
   {@
   $oDB = &DB::getInstance();
   $db_info = Context::getDBInfo();
   $prefix = $db_info->master_db['db_table_prefix'];
   //공지사항 갯수 구하기
   $query = $oDB->_query("select count(*) as cnt from ".$prefix."documents where module_srl = ".$module_info->module_srl." and is_notice = 'Y'");
   $result = $oDB->_fetch($query);
   //공지사항 갯수
   $noticeCnt = $result->cnt;

   //동일 모듈내 같은 카테고리 내 공지사항 갯수 구하기
   $cat_srl = $category_list[$document->get('category_srl')]->category_srl;
   $cat_query = $oDB->_query("select count(*) as cnt from ".$prefix."documents where module_srl = ".$module_info->module_srl." and category_srl = ".$cat_srl." and is_notice = 'Y'");
   $cat_result = $oDB->_fetch($cat_query);
   //해당 카테고리 내 공지시항의 갯수
   $CatNotice_cnt = $cat_result->cnt;

   //0부터 시작하기에 +1한후에, 공지사항 갯수만큼 빼주기 // $CatNotice_cnt 를 빼주기

   //공지사항이 아닌 전체 게시물 구하기
   $total_count_query = $oDB->_query("select count(*) as cnt from ".$prefix."documents where module_srl = ".$module_info->module_srl." and is_notice = 'N'");
   $total_count_result = $oDB->_fetch($total_count_query);
   $total_count_cnt = $total_count_result->cnt;

   //공지사항을 제외한 no 구하기
   $no_query = $oDB->_query("select count(*) as cnt from ".$prefix."documents where module_srl = ".$module_info->module_srl."");
   $no_result = $oDB->_fetch($no_query);
   $no_cnt = $no_result->cnt;

   //$category;
   $parent_srl = $category_list[$document->get('category_srl')]->parent_srl;
   $cat1st = $category == $parent_srl;
   }
   <!--@if($category)-->
      <!--@if($cat1st)-->
      {@ $turnNo = $total_count-$no}
      <!--@else-->
      {@ $turnNo = $total_count-$no+1-$CatNotice_cnt}
      <!--@end-->
   <!--@else-->
   {@ $turnNo = $total_count-$no+1-$noticeCnt}
   <!--@end-->

   <!--@if($turnNo==1)--><div class="no1">BEST<strong>1</strong></div>
   <!--@elseif($turnNo==2)--><div class="no2">BEST <strong>2</strong></div>
   <!--@elseif($turnNo==3)--><div class="no3">BEST<strong>3</strong></div>
   <!--@else-->{$turnNo}<!--@end-->
</div>

이온디

profile
이온디는 라이믹스를 비롯한 다양한 CMS의 시드뱅크를 꿈꿉니다. 여러분들이 사랑하는 웹소스를 언제든지 사용할 수 있게 하기 위해 이온디는 매일 소스코드를 유지보수하고 있으며, 언제든지 다운로드할 수 있는 소스마켓을 운영하고 있습니다.

#XE마켓 - 이온디스토어
https://eond.com/xemarket/

# XE/라이믹스 단톡방을 운영 중입니다. (비번: 2022)
https://open.kakao.com/o/giaKKnl

# XE/라이믹스 생활코딩 모듈 강좌입니다.
https://opentutorials.org/module/3774