Okay, I give up. I've stared at it too long, and tried too many variations. A little help for this ASP coder, please?

Would like for this function to print all on 1 line:

function loginbar() {
  global $user;                                                               
  $output = '';

  if (!$user->uid) {                                                          
    $output .= drupal_get_form('en_custom_login_block');                           
  }                                                                           
  else {                                                                      
    $output .= t('<p class="user-info">Member: !user - </p>', array('!user' => theme('username', $user)));
 
    $output .= theme('item_list', array(
      l(t('Your account - '), 'user/'.$user->uid, array('title' => t('My account'))),
      l(t('Sign out'), 'logout')));
  }
   
  $output = '<div id="user-bar">'.$output.'</div>';
     
  return $output;
}

Thank you!

Comments

Jeff Burnz’s picture

Keep t() clean, text only, not likely we want class names etc translatable, I'd probably be more inclined to do it like this...

function loginbar() {
  global $user;
  $output = '';

  if (!$user->uid) {
    $output .= drupal_get_form('en_custom_login_block');
  }
  else {
    $user_name = theme('username', $user);
    $output .= '<p class="user-info">'. t('Member') .': '. $user_name .' - </p>';

    $output .= theme('item_list', array(
      l(t('Your account') . ' - ', 'user/'.$user->uid, array('title' => t('My account'))),
      l(t('Sign out'), 'logout')));
  }

  $output = '<div id="user-bar">'. $output .'</div>';

  return $output;
}

To get it all on one line is a CSS jobby...

#user-bar p,
#user-bar div.item-list,
#user-bar ul,
#user-bar ul li {display: inline;}
#user-bar ul {margin:0;padding:0;}
#user-bar ul li {list-style: none;}
greta_drupal’s picture

Thank you for the reply, Jeff.

All I really needed was to apply the CSS to get it all on 1 line; thanks for saving me those steps. I just thought it would be tidier to write out the HTML on one line. But, this will work fine.

mooffie’s picture

t('Member') .': '. $user_name

You should not break a "sentence" like this. In French, for example, they put a space before a colon. (And there are other reasone, e.g., it's not always easy to translate a solitary word in a way that fits in differnet contexts.) So you better put it all inside the t() (with a placeholder for the username).

Jeff Burnz’s picture