fix: 쇼핑몰 5단계 분류 경로와 서브메뉴 표시 일관성 보완

PC·basic 테마 breadcrumb를 5단계로 확장하고 기존 위치와 스타일을 유지한다. PC·모바일 서브메뉴는 5단계가 있으면 해당 목록만, 없으면 4단계 형제 목록만 표시한다.

검증: 8개 분류 경로와 네 스킨의 메뉴·선택 상태, Chromium 목록·상세 단계별 레이아웃 검사, PHP 5.2 및 현재 PHP 구문 검사 통과.
This commit is contained in:
whitedot
2026-09-15 06:19:00 +00:00
parent c4cd61c916
commit e2d215c368
9 changed files with 252 additions and 219 deletions
+17 -36
View File
@@ -1,44 +1,25 @@
<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
if (!defined('_GNUBOARD_')) exit;
$str = '';
$exists = false;
$ca_id_len = strlen($ca_id);
$len2 = $ca_id_len + 2;
$sql = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where ca_id like '$ca_id%' and length(ca_id) = $len2 and ca_use = '1' order by ca_order, ca_id ";
$result = sql_query($sql);
// 하위 분류가 없으면 현재 분류를 포함한 같은 단계의 사용 중인 분류를 표시한다.
if (!sql_num_rows($result)) {
$parent_ca_id = substr($ca_id, 0, -2);
$sql = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where ca_id like '$parent_ca_id%' and length(ca_id) = $ca_id_len and ca_use = '1' order by ca_order, ca_id ";
$result = sql_query($sql);
}
while ($row=sql_fetch_array($result)) {
$row2 = sql_fetch(" select count(*) as cnt from {$g5['g5_shop_item_table']} where (ca_id like '{$row['ca_id']}%' or ca_id2 like '{$row['ca_id']}%' or ca_id3 like '{$row['ca_id']}%') and it_use = '1' ");
$current_attr = ($row['ca_id'] === $ca_id) ? ' class="sct_ct_here" aria-current="page"' : '';
$str .= '<li><a'.$current_attr.' href="'.shop_category_url($row['ca_id']).'">'.$row['ca_name'].' ('.$row2['cnt'].')</a></li>';
$exists = true;
}
if ($exists) {
// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
$category_groups = get_shop_category_menu_groups($ca_id);
if ($category_groups) {
add_stylesheet('<link rel="stylesheet" href="'.G5_SHOP_SKIN_URL.'/style.css">', 0);
?>
<!-- 상품분류 1 시작 { -->
<aside id="sct_ct_1" class="sct_ct">
<h2>현재 상품 분류와 관련된 분류</h2>
<ul>
<?php echo $str; ?>
<?php foreach ($category_groups as $category_group) { ?>
<ul aria-label="<?php echo $category_group['label']; ?>">
<?php foreach ($category_group['categories'] as $row) {
$row2 = sql_fetch(" select count(*) as cnt from {$g5['g5_shop_item_table']} where (ca_id like '{$row['ca_id']}%' or ca_id2 like '{$row['ca_id']}%' or ca_id3 like '{$row['ca_id']}%') and it_use = '1' ");
$current_attr = '';
if ($row['ca_id'] === $ca_id) {
$current_attr = ' class="sct_ct_here" aria-current="page"';
} elseif (strpos($ca_id, $row['ca_id']) === 0) {
$current_attr = ' class="sct_ct_here sct_ct_parent"';
}
echo '<li><a'.$current_attr.' href="'.shop_category_url($row['ca_id']).'">'.get_text($row['ca_name']).' ('.$row2['cnt'].')</a></li>';
} ?>
</ul>
<?php } ?>
</aside>
<!-- } 상품분류 1 끝 -->
<?php }
<?php }
+10 -37
View File
@@ -1,24 +1,9 @@
<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
$navi_datas = $ca_ids = array();
$is_item_view = (isset($it_id) && isset($it) && isset($it['it_id']) && $it_id === $it['it_id']) ? true : false;
if( !$is_item_view && $ca_id ){
$navi_datas = get_shop_navigation_data(true, $ca_id);
$ca_ids = array(
'ca_id' => substr($ca_id,0,2),
'ca_id2' => substr($ca_id,0,4),
'ca_id3' => substr($ca_id,0,6),
);
} else if( $is_item_view && isset($it) && is_array($it) ) {
$navi_datas = get_shop_navigation_data(true, $it['ca_id']);
$ca_ids = array(
'ca_id' => substr($it['ca_id'],0,2),
'ca_id2' => substr($it['ca_id'],0,4),
'ca_id3' => substr($it['ca_id'],0,6)
);
}
$is_item_view = (isset($it_id, $it['it_id']) && $it_id === $it['it_id']);
$navigation_ca_id = $is_item_view ? $it['ca_id'] : $ca_id;
$navi_datas = $navigation_ca_id ? get_shop_navigation_data(true, $navigation_ca_id) : array();
$location_class = array();
if($is_item_view){
@@ -27,7 +12,7 @@ if($is_item_view){
$location_class[] = 'is_list is_right'; // view_location는 리스트 말고 상품보기에서만 표시
}
// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
// add_stylesheet('css 구문', 출력순서);
add_stylesheet('<link rel="stylesheet" href="'.G5_SHOP_CSS_URL.'/style.css">', 0);
add_javascript('<script src="'.G5_JS_URL.'/shop.category.navigation.js"></script>', 10);
?>
@@ -37,26 +22,14 @@ add_javascript('<script src="'.G5_JS_URL.'/shop.category.navigation.js"></script
<i class="dividing-line fa fa-angle-right" aria-hidden="true"></i>
<?php if ( is_array($navi_datas) && $navi_datas ){ ?>
<?php if( isset($navi_datas[0]) && $navi_datas[0] ){ ?>
<select class="shop_hover_selectbox category1">
<?php foreach((array) $navi_datas[0] as $data ){ ?>
<option value="<?php echo $data['ca_id']; ?>" data-url="<?php echo $data['url']; ?>" <?php if($ca_ids['ca_id'] === $data['ca_id']) echo 'selected'; ?>><?php echo $data['ca_name']; ?></option>
<?php } ?>
</select>
<?php } ?>
<?php if( isset($navi_datas[1]) && $navi_datas[1] ){ ?>
<?php foreach ($navi_datas as $depth => $categories) {
$selected_ca_id = substr($navigation_ca_id, 0, ($depth + 1) * 2);
if ($depth > 0) { ?>
<i class="dividing-line fa fa-angle-right" aria-hidden="true"></i>
<select class="shop_hover_selectbox category2">
<?php foreach((array) $navi_datas[1] as $data ){ ?>
<option value="<?php echo $data['ca_id']; ?>" data-url="<?php echo $data['url']; ?>" <?php if($ca_ids['ca_id2'] === $data['ca_id']) echo 'selected'; ?>><?php echo $data['ca_name']; ?></option>
<?php } ?>
</select>
<?php } ?>
<?php if( isset($navi_datas[2]) && $navi_datas[2] ){ ?>
<i class="dividing-line fa fa-angle-right" aria-hidden="true"></i>
<select class="shop_hover_selectbox category3">
<?php foreach((array) $navi_datas[2] as $data ){ ?>
<option value="<?php echo $data['ca_id']; ?>" data-url="<?php echo $data['url']; ?>" <?php if($ca_ids['ca_id3'] === $data['ca_id']) echo 'selected'; ?>><?php echo $data['ca_name']; ?></option>
<select class="shop_hover_selectbox category<?php echo $depth + 1; ?>" aria-label="<?php echo $depth + 1; ?>단계 분류">
<?php foreach ($categories as $data) { ?>
<option value="<?php echo $data['ca_id']; ?>" data-url="<?php echo $data['url']; ?>"<?php if ($selected_ca_id === $data['ca_id']) echo ' selected'; ?>><?php echo get_text($data['ca_name']); ?></option>
<?php } ?>
</select>
<?php } ?>