User login

Return user to current page: How to link to a form from a Drupal menu

Searched words: 
drupal include current destination in link add redirect to menu link

Press login / press account links for anonymous and logged in users, respectively. Subtly added to a bottom menu. Via code in order to allow for the redirect back to the page you were on after login or editing.

There is surely a way, or should be a way, that does not involve hook_page_alter(), but hey, this works.

<?php
/**
* Implements hook_page_alter().
*/
function feature_final_page_alter(&$page) {
  if ($menu =& $page['footer']['menu_menu-utility']) {
    if ($menu['378']['#attributes']['class'][0] == 'last') {
      unset($menu['378']['#attributes']['class'][0]);
    }
    global $user;
    if (!$user->uid) {
      // If anonymous, set link and link title accordingly.
      // Note:  Path will be handed to l() and thus url().
      $path = 'user';
      $title = t('Press login');
      $tooltip = t('Sign in or register for media-only access to high-resolution images and more.');
    }
    else {
      // The user is logged in, direct them to their account page.
      $path = 'user/' . $user->uid . '/edit';
      $title = t('Press account');
      $tooltip = t('Manage your contact information.');
    }
    $menu['feature_final_press'] = array(
      '#theme' => 'menu_link__menu_utility',
      '#attributes' => array(
        'class' => array(
          0 => 'last',
          1 => 'leaf',
        ),
      ),
      '#title' => $title,
      '#href' => $path,
      '#localized_options' => array(
        'query' => drupal_get_destination(),
        'attributes' => array(
          'title' => $tooltip,
        ),
      ),
      '#below' => array(),
    );
  }
}
?>

Comments

It also will enable one

It also will enable one Windows 8 to edit records saved in Microsoft Windows 8 your server also once you are Office 2010 using the help of Microsoft Office 2010 . These modifications are instantly MS Office 2010 synchronized once you arrive Office 2010 Download . Download Office 2010 this can not merely Office 2010 Professional help you spend less time but money as Microsoft Office 2010 Download really nicely by aiding one to set up and operate company business office around the private computer, laptop, Online, and sensible phones.
Microsoft Office 2011 gorgeous exhibits with company Office 2007 which can make you Microsoft Office 2007 standout from some others. It creates it MS Office 2007 feasible for yourself to create Office 2007 Download incredible presentations by incorporating Office 2007 Professional electronic digital content Download Office 2007 material and films in Microsoft Office 2007 Professional . These displays are effortlessly Microsoft Office 2007 Download developed with out Windows 7 any Buy Windows 7 need of high priced resource. You will make Microsoft Windows 7 your displays witnessed to Win 7 everybody during the sort of Download Windows 7 .

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Syntax highlight code surrounded by the {syntaxhighlighter SPEC}...{/syntaxhighlighter} tags, where SPEC is a Syntaxhighlighter options string or "class="OPTIONS" title="the title".
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.