구조
home / dep1 / dep2 / dep3(있으면)
<?php
$sruri = $_SERVER["REQUEST_URI"];
// Define the breadcrumb structure
$breadcrumbs = [
'company' => [
'label' => '회사소개',
'url' => '/ko/company/greeting.php',
'sub' => [
'greeting' => ['label' => '인사말', 'url' => '/ko/company/greeting.php'],
'overview' => ['label' => '회사개요', 'url' => '/ko/company/overview.php'],
'orgChart' => ['label' => '조직도', 'url' => '/ko/company/orgChart.php'],
'directions' => ['label' => '오시는길', 'url' => '/ko/company/directions.php']
]
],
'factory' => [
'label' => '사업장소개',
'url' => '/ko/factory/factory.php',
'sub' => [
'factory' => ['label' => '사업장소개', 'url' => '/ko/factory/factory.php'],
'factory1' => ['label' => '1공장', 'url' => '/ko/factory/factory1.php'],
'factory2' => ['label' => '2공장', 'url' => '/ko/factory/factory2.php'],
'factory3' => ['label' => '3공장', 'url' => '/ko/factory/factory3.php'],
'factory4' => ['label' => '4공장', 'url' => '/ko/factory/factory4.php']
]
],
'business' => [
'label' => '사업소개',
'url' => '/ko/business/heavy/excavators.php',
'sub' => [
'heavy' => [
'label' => '중장비 사업',
'url' => '/ko/business/heavy/excavators.php',
'sub' => [
'excavators' => ['label' => '굴삭기', 'url' => '/ko/business/heavy/excavators.php'],
'wheel_loader' => ['label' => '휠로더', 'url' => '/ko/business/heavy/wheel_loader.php'],
'bulldozer' => ['label' => '불도저', 'url' => '/ko/business/heavy/bulldozer.php'],
'mining_equipment' => ['label' => '광산장비', 'url' => '/ko/business/heavy/mining_equipment.php'],
'large_wheel_loader' => ['label' => '초대형 휠로더', 'url' => '/ko/business/heavy/large_wheel_loader.php'],
'aerial_work' => ['label' => '고소작업차량', 'url' => '/ko/business/heavy/aerial_work.php'],
'pressure_vessel' => ['label' => 'PRESSURE VESSEL', 'url' => '/ko/business/heavy/pressure_vessel.php']
]
],
'plant' => [
'label' => '플랜트 사업',
'url' => '/ko/business/plant/business_areas.php',
'sub' => [
'business_areas' => ['label' => '사업영역', 'url' => '/ko/business/plant/business_areas.php'],
'products' => ['label' => '주요제품', 'url' => '/ko/business/plant/products.php'],
'case' => ['label' => '시공실적', 'url' => '/ko/business/plant/case.php'],
'license' => ['label' => '보유면허', 'url' => '/ko/business/plant/license.php']
]
]
]
],
'rnd' => [
'label' => '연구개발',
'url' => '/ko/rnd/institute.php',
'sub' => [
'institute' => ['label' => '기술연구소', 'url' => '/ko/rnd/institute.php'],
'production_facilities' => ['label' => '생산설비', 'url' => '/ko/rnd/production_facilities.php'],
'measuring_equipment' => ['label' => '측정설비', 'url' => '/ko/rnd/measuring_equipment.php']
]
],
'prcenter' => [
'label' => '홍보센터',
'url' => '/board/bbs/board.php?bo_table=news',
'sub' => [
'news' => ['label' => '회사뉴스', 'url' => '/board/bbs/board.php?bo_table=news'],
'catalog' => ['label' => '카탈로그', 'url' => '/ko/prcenter/catalog.php'],
'video' => ['label' => '홍보영상', 'url' => '/ko/prcenter/video.php']
]
],
'cs' => [
'label' => '고객센터',
'url' => '/board/bbs/board.php?bo_table=notice',
'sub' => [
'notice' => ['label' => '공지사항', 'url' => '/board/bbs/board.php?bo_table=notice'],
'inquiry' => ['label' => '문의사항', 'url' => '/ko/cs/inquiry.php'],
'directions' => ['label' => '오시는 길', 'url' => '/ko/cs/directions.php']
]
]
];
function getBreadcrumb($sruri, $breadcrumbs) {
foreach ($breadcrumbs as $key => $data) {
if (strpos($sruri, "/$key/") !== false) {
echo "<span>{$data['label']}<i class='xi-angle-down-min'></i></span>";
echo "<ul>";
foreach ($data['sub'] as $subKey => $subData) {
echo "<li><a href='{$subData['url']}'>{$subData['label']}</a></li>";
}
echo "</ul>";
return $data['sub'];
}
}
return [];
}
function getSubBreadcrumb($sruri, $subItems) {
foreach ($subItems as $subKey => $subData) {
if (strpos($sruri, $subKey) !== false) {
echo "<span>{$subData['label']}<i class='xi-angle-down-min'></i></span>";
echo "<ul>";
foreach ($subItems as $item) {
echo "<li><a href='{$item['url']}'>{$item['label']}</a></li>";
}
echo "</ul>";
return isset($subData['sub']) ? $subData['sub'] : [];
}
}
return [];
}
?>
<div id="breadcrumbs">
<div class="inner">
<div class="home">
<a href="/ko/main.php"><i class="xi-home-o"></i></a>
</div>
<!-- dep1 -->
<div class="dep1">
<?php $subItems = getBreadcrumb($sruri, $breadcrumbs); ?>
</div>
<!-- dep2 -->
<div class="dep2">
<?php if (!empty($subItems)) : ?>
<?php $subSubItems = getSubBreadcrumb($sruri, $subItems); ?>
<?php endif; ?>
</div>
<!-- dep3 -->
<div class="dep3">
<?php if (!empty($subSubItems)) : ?>
<?php
foreach ($subSubItems as $subSubKey => $subSubData) {
if (strpos($sruri, $subSubKey) !== false) {
echo "<span>{$subSubData['label']}<i class='xi-angle-down-min'></i></span>";
echo "<ul>";
foreach ($subSubItems as $item) {
echo "<li><a href='{$item['url']}'>{$item['label']}</a></li>";
}
echo "</ul>";
}
}
?>
<?php endif; ?>
</div>
</div>
</div>
728x90