Show / hide Menu items

Post Reply
User avatar
cobber
Master Bludit
Posts: 78
Joined: Sun Feb 28, 2016 10:15 am
Location: Scotland
Has thanked: 21 times
Been thanked: 5 times

Wondering if anyone has managed to specifically select pages to appear or hide in the main navigation. Does Bludit possess this functionality to select whether a page link is visible in the menu bar or not as I can't seem to see it.

Thanks
User avatar
arakel2
Ssr. Bludit
Posts: 24
Joined: Sun Mar 28, 2021 11:14 am
Has thanked: 1 time

Hi cobber,

the best solution for this feature is to use custom fields and to modify a php file of the theme you are using.
At [Settings]-[General]-[Custom fields] add:

Code: Select all

{
    "ShowMenu": {
        "type": "bool",
        "label": "Show in Menu",
        "tip": "Don't show page in menu."
    }
}
This will give you a new checkbox in the Option-Custom menu of your page.
ShowMenu.png
ShowMenu.png (17.68 KiB) Viewed 1099 times

Next you have edit the file navbar.php in bl-themes/YOUR_THEME/php/
Find:

Code: Select all

<!-- Static pages -->
<?php foreach ($staticContent as $staticPage): ?>
<li class="nav-item">
<a class="nav-link" href="<?php echo $staticPage->permalink(); ?>"><?php echo $staticPage->title(); ?></a>
</li>
<?php endforeach ?>
Add an if statement:

Code: Select all

<!-- Static pages -->
<?php foreach ($staticContent as $staticPage):
if ( !$staticPage->custom('ShowMenu')) { ?>
<li class="nav-item">
<a class="nav-link" href="<?php echo $staticPage->permalink() ?>"><?php echo $staticPage->title() ?></a>
</li>
<?php } endforeach ?>
Now if you check the box "Don't show page in menu." of a page, this page will not show up in the menu.
Post Reply