Jump to content

Recommended Posts

Posted

I am not sure whether this has been asked before. I tried googling, but got slightly different topics, so I post this as a new topic now. Sorry.

I have a «protected» page. The guest user is not allowed to view this page, only a few roles. Now the customer want this page to appear in the navigation even for guest users. When they click on the item they should be presented with the Processwire login then they should be able to view the protected page. This works if I give them the direct link, and if they are logged in, the protected page also appears in the navigation.

This is the code for the navigation. It's a two-level navigation. Sorry about the alternative syntax. I know it's controversial, but I like it for templating.

  <? foreach (top_pages() as $top): ?>
    <li id="nav_<?=$top->id?>" class="top">
      <a href="<?=$top->url?>"><?=$top->title?></a>
      <? if ($top->numChildren): ?>
        <ul>
          <? foreach ($top->children as $child): ?>
            <li class="sub"><a href="<?=$child->url?>"><?=$child->title?></a></li>
          <? endforeach ?>
        </ul>
      <? endif ?>
    </li>
  <? endforeach ?>

Now, how can I get the children of $top as a given role even when not logged in?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...