PHP code example of log1x / navi
1. Go to this page and download the library: Download log1x/navi library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
log1x / navi example snippets
use Log1x\Navi\Navi;
$menu = Navi::make()->build('primary_navigation');
if ($menu->isNotEmpty()) {
return $menu->all();
}
$menu = Navi::make()->withDefaultClasses()->build();
$menu = Navi::make()->withoutClasses(['shop-'])->build();
$menu->get()->name;
$menu->get('name', 'My menu title');
$type = get_post_type($item->objectId)
$label = get_field('custom_menu_label', $item->id) ?: $item->label;
<x-menu name="footer_navigation" />
array [
5 => {
+"active": true
+"activeAncestor": false
+"activeParent": false
+"classes": "example"
+"dbId": 5
+"description": false
+"id": 5
+"label": "Home"
+"object": "page"
+"objectId": "99"
+"parent": false
+"slug": "home"
+"target": "_blank"
+"title": false
+"type": "post_type"
+"url": "https://sage.test/"
+"xfn": false
+"order": 1
+"parentObjectId": false
+"children": false
}
6 => {
+"active": false
+"activeAncestor": false
+"activeParent": false
+"classes": false
+"dbId": 6
+"description": false
+"id": 6
+"label": "Sample Page"
+"object": "page"
+"objectId": "100"
+"parent": false
+"slug": "sample-page"
+"target": false
+"title": false
+"type": "post_type"
+"url": "https://sage.test/sample-page/"
+"xfn": false
+"order": 2
+"parentObjectId": false
+"children": array [
7 => {
+"active": false
+"activeAncestor": false
+"activeParent": false
+"classes": false
+"dbId": 7
+"description": false
+"id": 7
+"label": "Example"
+"object": "custom"
+"objectId": "101"
+"parent": 6
+"slug": "example"
+"target": false
+"title": false
+"type": "custom"
+"url": "#"
+"xfn": false
+"order": 3
+"parentObjectId": 100
+"children": array [
...
]
}
]
}
]