I’m using this plugin
But how do I make it not show links when generating out something like this. Basically, we don’t want to show that the page exists for certain people.
<nav>
<ul>
<?php foreach($items as $item): ?>
<li><a<?php e($item->isOpen(), ' class="active"') ?> href="<?php echo $item->url() ?>"><?php echo $item->title()->html() ?></a></li>
<?php endforeach ?>
</ul>
</nav>
texnixe
2
Check if a user is locked in and if this user has the right to view the page for each item:
<nav>
<ul>
<?php foreach($items as $item): ?>
<?php if(($user = $site->user()) && $user->role() == $item->accessControlField()->value()): ?>
<li><a<?php e($item->isOpen(), ' class="active"') ?> href="<?php echo $item->url() ?>"><?php echo $item->title()->html() ?></a></li>
<?php endif ?>
<?php endforeach ?>
</ul>
</nav>
You might have to adapt the second condition, I don’t know what is stored in your field.
Keep in mind that you can not use cache with this technique.
texnixe
4
Looking at what is saved to file, the if statement has to be changed a bit:
<?php
$firewall = $page->firewall()->yaml();
if(($user = $site->user()) && in_array($user->role(), $firewall['roles'])):
// your code
endif;