breadcrumbs van uit menu

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Derk  Janssen

Derk Janssen

01/03/2014 13:47:50
Quote Anchor link
Beste allemaal,

Ik probeer breadcrumbs te maken van uit een hiërarchisch menu.
Maar ik weet niet hoe ik moet beginnen zijn er mensen hier die me een klein opzetje kunnen geven van uit deze class van het menu.

Quote:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php

class J_Menu {

    public function __construct($dB, $Page_name, $Style_1 = "", $Style_2 = "", $Rights = "") {
        $this->db = $dB;
        $this->page_name = $Page_name;
        $this->url = new j_Rewrite();
    }

    function
getMenus($menu_id) {
        $html = "";

        $aclData = new J_Acl($this->db);

        $menus = $this->db->selectData('cms_menus', 'menu_id="' . $menu_id . '" AND menu_tld="' . $_SESSION['languages_id'] . '"');
        if ($menus[0]->menu_published == 1) {
            if ($menus[0]->menu_permissions == 'public') {
                $Permission = true;
            }
else {
                $Permission = $aclData->hasPermission($menus[0]->menu_permissions);
            }

            if (($Permission == true)) {
                if ($this->page_name == $menus[0]->menu_view_on OR $menus[0]->menu_view_on == 'all') {

                    $html .= $this->getMenuItems($menu_id);
                }
            }
        }
else {
            $html .= "";
        }

        return $html;
    }

    function
dbitems($menu_id) {
        $rows = array();

        foreach ($this->db->selectData('cms_menu_items', 'menu_items_menu_id="' . $menu_id . '" AND menu_items_tld="' . $_SESSION['languages_id'] . '"', '*', 'sort ASC') AS $menu_items) {
            $rows[] = array('menu_items_id' => $menu_items->menu_items_id, 'menu_items_title' => $menu_items->menu_items_title, 'menu_items_link' => $menu_items->menu_items_link, 'menu_items_parent_id' => $menu_items->menu_items_parent_id, 'menu_items_permissions' => $menu_items->menu_items_permissions, 'menu_items_published' => $menu_items->menu_items_published);
        }

        return $rows;
    }

    function
getMenuItems($menu_id) {
        foreach ($this->dbitems($menu_id) as $item)
            $children[$item['menu_items_parent_id']][] = $item;

        $html = '';
        $root = 0;
        $loop = !empty($children[$root]);
        $parent = $root;
        $stack = array();
        $aclData = new J_Acl($this->db);

        $html .= '<ul>';
        while ($loop && (($option = each($children[$parent])) || ($parent > $root))) {

            if (!$option) {
                $parent = array_pop($stack);
                $html .= '</ul>' . "\n" . '</li>' . "\n"; //closing a submenu
                $counter = 0;
            }
else if (!empty($children[$option['value']['menu_items_id']])) {
                if ($option['value']['menu_items_published'] == 1) {
                    if ($option['value']['menu_items_permissions'] == 'public') {
                        $Permission = true;
                    }
else {
                        $Permission = $aclData->hasPermission($option['value']['menu_items_permissions']);
                    }


                    $html .= '<li>';

                    if ($option['value']['menu_items_link'] != NULL) {
                        $html .="<a ";
                        if ($option['value']['menu_items_link'] == $this->page_name) {
                            $html .= 'class="active"';
                        }

                        // $active = ($option['value']['menu_item_link'] == $this->options['current_path']) ? true : false;
                        $html .= 'href="' . $option['value']['menu_items_link'] . '">' . $option['value']['menu_items_title'] . "</a>\n";
                    }
else {
                        $html .= $option['value']['menu_items_title'];
                    }

                    $html .= '<ul class="submenu">' . "\n";
                    array_push($stack, $option['value']['menu_items_parent_id']);
                    $parent = $option['value']['menu_items_id'];
                }
            }
else {
                if ($option['value']['menu_items_published'] == 1) {
                    if ($option['value']['menu_items_permissions'] == 'public') {
                        $Permission = true;
                    }
else {

                        $Permission = $aclData->hasPermission($option['value']['menu_items_permissions']);
                    }


                    if (($Permission == true)) {
                        $html .= '<li>';
                        if ($option['value']['menu_items_link'] != NULL) {
                            $html .="<a ";
                            if ($option['value']['menu_items_link'] == $this->page_name) {
                                $html .= 'class="active"';
                            }

                            // $active = ($option['value']['menu_item_link'] == $this->options['current_path']) ? true : false;
                            $html .= ' href="' . $option['value']['menu_items_link'] . '">' . $option['value']['menu_items_title'] . '</a>';
                        }
else {
                            $html .= $option['value']['menu_items_title'];
                        }

                        $html .='</li>' . "\n";
                    }
                }
            }
        }



        $html .= '</ul>';

        return $html;
    }

}


?>
Gewijzigd op 01/03/2014 14:00:22 door Derk Janssen
 
Er zijn nog geen reacties op dit bericht.



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.