Hi
how do I hide the primary and secondary links from anynomous users?
I have placed a 'logout' button in the topright corner of the page
and I think it's stupid to logout when you are not logged in yet.

Okay, so far, I think it has to be done with an access control in php but
I'm not sure and I hope somebody is able to help me with that!

thank you very much
regards
neablo

PS the drupal version is 4.6.5 and the the template engine phptemp with friendselectric

Comments

q0rban’s picture

check out this snippet... it may be just what you are looking for...

otherwise, change this code (on line 31 of page.tpl.php):

  <div id="top-nav">
    <?php if (is_array($primary_links) && !empty($primary_links)): ?>
      <ul id="primary">
      <?php foreach ($primary_links as $link): ?>
        <li><?php print phptemplate_wrap_links($link, 2); ?></li>
      <?php endforeach; ?>
      </ul>
    <?php endif; ?>

    <?php if (is_array($secondary_links) && !empty($secondary_links)): ?>
      <ul id="secondary">
      <?php foreach (array_reverse($secondary_links) as $link): ?>
        <li><?php print phptemplate_wrap_links($link, 2); ?></li>
      <?php endforeach; ?>
      </ul>
    <?php endif; ?>
  </div>

to this:

  <div id="top-nav">
    <?php
      global $user;
      if ($user->uid) { ?>
        <?php if (is_array($primary_links) && !empty($primary_links)): ?>
          <ul id="primary">
          <?php foreach ($primary_links as $link): ?>
            <li><?php print phptemplate_wrap_links($link, 2); ?></li>
          <?php endforeach; ?>
          </ul>
        <?php endif; ?>
    
        <?php if (is_array($secondary_links) && !empty($secondary_links)): ?>
          <ul id="secondary">
          <?php foreach (array_reverse($secondary_links) as $link): ?>
            <li><?php print phptemplate_wrap_links($link, 2); ?></li>
          <?php endforeach; ?>
          </ul>
        <?php endif; ?>
      <?php } ?>        
  </div>

I haven't actually tested that, so hopefully it works for you..

neablo’s picture

hey man
thank you so much, works perfect!

The snippet was not what I've been looking for but your code was!

thanks again