순번을 1-2-3 순으로 띄우고 공지사항 있을 경우 공지사항은 제외하기
게시물 순번을 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>

eond
Lv. 12
댓글 0