-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathBreadcrumb.php
50 lines (40 loc) · 1.36 KB
/
Breadcrumb.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
namespace Addon\Breadcrumb;
defined('is_running') or die('Not an entry point...');
class Breadcrumb{
function __construct(){
global $gp_menu, $page, $addonPathData;
$config = \gpFiles::Get($addonPathData.'/config.php', 'config');
$items = array(
'Bootstrap' => array(
'ol' => '<ol class="breadcrumb">',
'li' => '<li class="breadcrumb-item">%s</li>',
'active' => '<li class="breadcrumb-item active" aria-current="page">%s</li>',
'nav' => '</ol></nav>'
),
'Foundation' => array(
'ol' => '<ol class="breadcrumbs">',
'li' => '<li>%s</li>',
'active' => '<li>%s</li>',
'nav' => '</ol></nav>'
),
'Simple' => array(
'ol' => '',
'li' => '%s '.(isset($config['separator']) ? $config['separator'] : '>').' ',
'active' => '%s',
'nav' => '</nav>'
)
);
$style = isset($config['style']) ? $config['style'] : 'Simple';
$pages = \common::Parents($page->gp_index, $gp_menu);
$pages[] = \common::GetLabel(key($gp_menu));
echo '<nav aria-label="breadcrumb" role="navigation">'.$items[$style]['ol'];
for ($i = count($pages)-1; $i >= 0; $i--){
$title = \common::IndexToTitle($pages[$i]);
if($pages[$i] != $page->gp_index)
printf($items[$style]['li'], \common::Link($title, \common::GetLabel($title)));
}
printf($items[$style]['active'], $page->label);
echo $items[$style]['nav'];
}
}