영카트 카테고리 분류별 정렬시 1차 2차 3차 구분해서 가져오기
영카트에서 분류 정렬순서를 변경하면 순서대로만 나와서 분류구분이 되지 않아 순서대로
정렬시 1차 2차 3차 범위안에서 낮은 순서대로 정렬
1차카테고리 순서가 낮은 것 부터 정렬후 하위 카테고리가 있으면 하위 카테고리도 낮은순서로 정렬된
리스트를 가져오게 했습니다.
자료를 찾다 못찾아 그냥 만들었습니다.
저와 같이 고민하시는 분이 있을까 해서 소스를 올려봅니다.
// lib/shop.lib.php 경로 맨하단에 추가
/************************************************************************/
/* shop.lib.php 파일*/
/************************************************************************/
//카테고리 정렬 select
function get_select_category($name,$selected=''){
$option_txt ="<option value=''>전체분류</option>";
//1차카테고리 가져오기
$sql ="select ca_id, ca_name from g5_shop_category where length(ca_id) ='2' order by ca_order,
ca_id ";
$result =sql_query($sql);
while($row =sql_fetch_array($result)){
if($selected == $row['ca_id']){
$selected1 ="selected";
}else{
$selected1 ="";
}
$option_txt .="<option value='".$row['ca_id']."' ".$selected1.">".$row
['ca_name']."</option>";
//2차 카테고리 가져오기
$sql2 ="select ca_id, ca_name from g5_shop_category where length(ca_id) ='4' and ca_id like
'{$row['ca_id']}%' order by ca_order, ca_id ";
$result2 =sql_query($sql2);
while($row2 =sql_fetch_array($result2)){
// echo $selected."||".$row2['ca_id']."<br>";
if($selected == $row2['ca_id']){
$selected2 ="selected";
}else{
$selected2 ="";
}
$option_txt .="<option value='".$row2['ca_id']."' ".$selected2."> ".
$row2['ca_name']."</option>";
//3차 카테고리 가져오기
$sql3 ="select ca_id, ca_name from g5_shop_category where length(ca_id) ='6' and ca_id
like '{$row2['ca_id']}%' order by ca_order, ca_id ";
$result3 =sql_query($sql3);
while($row3 =sql_fetch_array($result3)){
if($selected == $row3['ca_id']){
$selected3 ="selected";
}else{
$selected3 ="";
}
//3차 카테고리 가져오기
$option_txt .="<option value='".$row3['ca_id']."' ".$selected3.">
".$row3['ca_name']."</option>";
}
}
}
$str = "<select id='".$name."' name='".$name."'>".$option_txt."</select>";
return $str;
}
/************************************************************************/
/* /adm/shop_admin/itemlist.php 파일*/
/* select box 부분은 주석처리후 아래 소스로 대체 합니다.
$get_cate= get_select_category("sca");
echo($get_cate); */
/************************************************************************/
<label for="sca" class="sound_only">분류선택</label>
<?php
$get_cate= get_select_category("sca");
echo($get_cate);
?>
<!--<select name="sca" id="sca">
<option value="">전체분류</option>
<?php
/* $sql1 = " select ca_id, ca_name from {$g5['g5_shop_category_table']} order by ca_order, ca_id
";
$result1 = sql_query($sql1);
for ($i=0; $row1=sql_fetch_array($result1); $i++) {
$len = strlen($row1['ca_id']) / 2 - 1;
$nbsp = '';
for ($i=0; $i<$len; $i++) $nbsp .= ' ';
echo '<option value="'.$row1['ca_id'].'" '.get_selected($sca, $row1['ca_id']).'>'.$nbsp.
$row1['ca_name'].'</option>'.PHP_EOL;
}
*/?>
</select>-->
<td colspan="5" class="td_sort">
<label for="ca_id_<?php echo $i; ?>" class="sound_only"><?php echo get_text($row
['it_name']); ?> 기본분류</label>
<!-- <select name="ca_id[<?php /*echo $i; */?>]" id="ca_id_<?php /*echo $i; */?>">
<?php /*echo conv_selected_option($ca_list, $row['ca_id']); */?>
</select>-->
<?php
$get_cate= get_select_category("ca_id[$i]",$row['ca_id']);
echo($get_cate);
?>
<label for="ca_id2_<?php echo $i; ?>" class="sound_only"><?php echo get_text($row
['it_name']); ?> 2차분류</label>
<!--<select name="ca_id2[<?php /*echo $i; */?>]" id="ca_id2_<?php /*echo $i; */?>">
<?php /*echo conv_selected_option($ca_list, $row['ca_id2']); */?>
</select>-->
<?php
$get_cate2= get_select_category("ca_id2[$i]",$row['ca_id2']);
echo($get_cate2);
?>
<label for="ca_id3_<?php echo $i; ?>" class="sound_only"><?php echo get_text($row
['it_name']); ?> 3차분류</label>
<!--<select name="ca_id3[<?php /*echo $i; */?>]" id="ca_id3_<?php /*echo $i; */?>">
<?php /*echo conv_selected_option($ca_list, $row['ca_id3']); */?>
</select>-->
<?php
$get_cate3= get_select_category("ca_id3[$i]",$row['ca_id3']);
echo($get_cate3);
?>
</td>
정렬시 1차 2차 3차 범위안에서 낮은 순서대로 정렬
1차카테고리 순서가 낮은 것 부터 정렬후 하위 카테고리가 있으면 하위 카테고리도 낮은순서로 정렬된
리스트를 가져오게 했습니다.
자료를 찾다 못찾아 그냥 만들었습니다.
저와 같이 고민하시는 분이 있을까 해서 소스를 올려봅니다.
// lib/shop.lib.php 경로 맨하단에 추가
/************************************************************************/
/* shop.lib.php 파일*/
/************************************************************************/
//카테고리 정렬 select
function get_select_category($name,$selected=''){
$option_txt ="<option value=''>전체분류</option>";
//1차카테고리 가져오기
$sql ="select ca_id, ca_name from g5_shop_category where length(ca_id) ='2' order by ca_order,
ca_id ";
$result =sql_query($sql);
while($row =sql_fetch_array($result)){
if($selected == $row['ca_id']){
$selected1 ="selected";
}else{
$selected1 ="";
}
$option_txt .="<option value='".$row['ca_id']."' ".$selected1.">".$row
['ca_name']."</option>";
//2차 카테고리 가져오기
$sql2 ="select ca_id, ca_name from g5_shop_category where length(ca_id) ='4' and ca_id like
'{$row['ca_id']}%' order by ca_order, ca_id ";
$result2 =sql_query($sql2);
while($row2 =sql_fetch_array($result2)){
// echo $selected."||".$row2['ca_id']."<br>";
if($selected == $row2['ca_id']){
$selected2 ="selected";
}else{
$selected2 ="";
}
$option_txt .="<option value='".$row2['ca_id']."' ".$selected2."> ".
$row2['ca_name']."</option>";
//3차 카테고리 가져오기
$sql3 ="select ca_id, ca_name from g5_shop_category where length(ca_id) ='6' and ca_id
like '{$row2['ca_id']}%' order by ca_order, ca_id ";
$result3 =sql_query($sql3);
while($row3 =sql_fetch_array($result3)){
if($selected == $row3['ca_id']){
$selected3 ="selected";
}else{
$selected3 ="";
}
//3차 카테고리 가져오기
$option_txt .="<option value='".$row3['ca_id']."' ".$selected3.">
".$row3['ca_name']."</option>";
}
}
}
$str = "<select id='".$name."' name='".$name."'>".$option_txt."</select>";
return $str;
}
/************************************************************************/
/* /adm/shop_admin/itemlist.php 파일*/
/* select box 부분은 주석처리후 아래 소스로 대체 합니다.
$get_cate= get_select_category("sca");
echo($get_cate); */
/************************************************************************/
<label for="sca" class="sound_only">분류선택</label>
<?php
$get_cate= get_select_category("sca");
echo($get_cate);
?>
<!--<select name="sca" id="sca">
<option value="">전체분류</option>
<?php
/* $sql1 = " select ca_id, ca_name from {$g5['g5_shop_category_table']} order by ca_order, ca_id
";
$result1 = sql_query($sql1);
for ($i=0; $row1=sql_fetch_array($result1); $i++) {
$len = strlen($row1['ca_id']) / 2 - 1;
$nbsp = '';
for ($i=0; $i<$len; $i++) $nbsp .= ' ';
echo '<option value="'.$row1['ca_id'].'" '.get_selected($sca, $row1['ca_id']).'>'.$nbsp.
$row1['ca_name'].'</option>'.PHP_EOL;
}
*/?>
</select>-->
<td colspan="5" class="td_sort">
<label for="ca_id_<?php echo $i; ?>" class="sound_only"><?php echo get_text($row
['it_name']); ?> 기본분류</label>
<!-- <select name="ca_id[<?php /*echo $i; */?>]" id="ca_id_<?php /*echo $i; */?>">
<?php /*echo conv_selected_option($ca_list, $row['ca_id']); */?>
</select>-->
<?php
$get_cate= get_select_category("ca_id[$i]",$row['ca_id']);
echo($get_cate);
?>
<label for="ca_id2_<?php echo $i; ?>" class="sound_only"><?php echo get_text($row
['it_name']); ?> 2차분류</label>
<!--<select name="ca_id2[<?php /*echo $i; */?>]" id="ca_id2_<?php /*echo $i; */?>">
<?php /*echo conv_selected_option($ca_list, $row['ca_id2']); */?>
</select>-->
<?php
$get_cate2= get_select_category("ca_id2[$i]",$row['ca_id2']);
echo($get_cate2);
?>
<label for="ca_id3_<?php echo $i; ?>" class="sound_only"><?php echo get_text($row
['it_name']); ?> 3차분류</label>
<!--<select name="ca_id3[<?php /*echo $i; */?>]" id="ca_id3_<?php /*echo $i; */?>">
<?php /*echo conv_selected_option($ca_list, $row['ca_id3']); */?>
</select>-->
<?php
$get_cate3= get_select_category("ca_id3[$i]",$row['ca_id3']);
echo($get_cate3);
?>
</td>
댓글 3개
5년 전
저도 그 부분 때문에 불편했는데 감사합니다.
qwaszx
4년 전
감사합니다
3년 전
카테고리별 순서
게시판 목록
영카트5 팁자료실
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 341 | 4년 전 | 4068 | ||
| 340 | 4년 전 | 3376 | ||
| 339 | 4년 전 | 3208 | ||
| 338 | 4년 전 | 3770 | ||
| 337 | 4년 전 | 4127 | ||
| 336 | 4년 전 | 2807 | ||
| 335 |
|
4년 전 | 2696 | |
| 334 | 4년 전 | 2252 | ||
| 333 |
|
4년 전 | 2314 | |
| 332 |
|
4년 전 | 3152 | |
| 331 |
|
4년 전 | 3798 | |
| 330 | 4년 전 | 2208 | ||
| 329 | 4년 전 | 3698 | ||
| 328 | 4년 전 | 2165 | ||
| 327 | 4년 전 | 2728 | ||
| 326 | 4년 전 | 2589 | ||
| 325 | 4년 전 | 5031 | ||
| 324 | 4년 전 | 2197 | ||
| 323 |
파이브스톤즈
|
5년 전 | 3022 | |
| 322 | 5년 전 | 2521 | ||
| 321 | 5년 전 | 2553 | ||
| 320 | 5년 전 | 1885 | ||
| 319 | 5년 전 | 2567 | ||
| 318 | 5년 전 | 4108 | ||
| 317 | 5년 전 | 4108 | ||
| 316 | 5년 전 | 2651 | ||
| 315 | 5년 전 | 3833 | ||
| 314 | 5년 전 | 3644 | ||
| 313 |
|
5년 전 | 1645 | |
| 312 | 5년 전 | 4153 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기