답변 1개
채택된 답변
+20 포인트
마르스컴퍼니
Expert
5개월 전
* /head.php 또는 /theme/[테마명]/head.php 메뉴 출력 코드 이후 적당한 위치에 삽입
</p>
<p><?php
// 메인페이지가 아닌 경우에만 브레드크럼 표시
if (!defined('_INDEX_')) {
// 현재 URL 정보 가져오기
$current_url = $_SERVER['REQUEST_URI'];
// 파라미터 추출
$bo_table = isset($_GET['bo_table']) ? $_GET['bo_table'] : '';
$co_id = isset($_GET['co_id']) ? $_GET['co_id'] : '';
// 현재 페이지 정보 초기화
$depth1 = null;
$depth2 = null;
$depth1_name = '';
$depth2_name = '';
$breadcrumb_html = '';
// 현재 페이지가 속한 메뉴 찾기
foreach ($menu_datas as $i => $row) {
if (empty($row)) continue;
// 1차 메뉴 링크와 현재 URL 비교
if (($bo_table && strpos($row['me_link'], 'bo_table='.$bo_table) !== false) ||
($co_id && strpos($row['me_link'], 'co_id='.$co_id) !== false) ||
(!$bo_table && !$co_id && strpos($current_url, $row['me_link']) !== false)) {
$depth1 = $i;
$depth1_name = $row['me_name'];
break;
}
// 2차 메뉴 링크와 현재 URL 비교
if (isset($row['sub']) && is_array($row['sub'])) {
foreach ($row['sub'] as $j => $row2) {
if (empty($row2)) continue;
if (($bo_table && strpos($row2['me_link'], 'bo_table='.$bo_table) !== false) ||
($co_id && strpos($row2['me_link'], 'co_id='.$co_id) !== false) ||
(!$bo_table && !$co_id && strpos($current_url, $row2['me_link']) !== false)) {
$depth1 = $i;
$depth2 = $j;
$depth1_name = $row['me_name'];
$depth2_name = $row2['me_name'];
break 2;
}
}
}
}
// 브레드크럼 구성
if ($depth1_name) {
$breadcrumb_html = '<div class="breadcrumb">';
$breadcrumb_html .= '<a href="'.G5_URL.'">홈</a>';
if ($depth1_name) {
$breadcrumb_html .= ' > <a href="'.$menu_datas[$depth1]['me_link'].'">'.$depth1_name.'</a>';
}
if ($depth2_name) {
$breadcrumb_html .= ' > <strong>'.$depth2_name.'</strong>';
}
$breadcrumb_html .= '</div>';
// 브레드크럼 출력
echo $breadcrumb_html;
}
}
?></p>
<p>
</p>
<p>.breadcrumb {
padding: 10px 0;
margin-bottom: 15px;
font-size: 14px;
}</p>
<p>.breadcrumb a {
color: #666;
}</p>
<p>.breadcrumb strong {
color: #333;
font-weight: 600;
}</p>
<p>
로그인 후 평가할 수 있습니다
답변에 대한 댓글 1개
�
버키
5개월 전
답변 감사드립니다!
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인