Snippet · Mecha CMS

Code snippet collection for developers.

Add Log In/Out Link

Author: Taufik Nurrohman · 434 Views

Tweet

Show log in/out link.

<!-- If we have `user` extension… -->
<?php if (Extend::exist('user')): ?>
  <!-- If user is logged in, add log out link! -->
  <?php if (Is::user()): ?>
    <a href="<?php echo $url . '/' . Extend::state('user', 'path'); ?>">
      <?php echo $language->log_out; ?>
    </a>
  <!-- If user is logged out, add log in link! -->
  <?php else: ?>
    <a href="<?php echo $url . '/' . Extend::state('user', 'path') . HTTP::query(['kick' => $url->path]); ?>">
      <?php echo $language->log_in; ?>
    </a>
  <?php endif; ?>
<?php endif; ?>
<!-- If we have `panel` extension… -->
<?php if (Extend::exist('panel')): ?>
  <!-- If user is logged in, add log out link! -->
  <?php if (Is::user()): ?>
    <a href="<?php echo $url . '/' . Extend::state('panel', 'path') . '/::g::/exit'; ?>">
      <?php echo $language->log_out; ?>
    </a>
  <!-- If user is logged out, add log in link! -->
  <?php else: ?>
    <a href="<?php echo $url . '/' . Extend::state('panel', 'path') . '/::g::/enter'; ?>">
      <?php echo $language->log_in; ?>
    </a>
  <?php endif; ?>
<?php endif; ?>

0 Comments

No comments yet.