When the user is logged in, the authorize div is empty.

CommentFileSizeAuthor
#1 page.tpl_.php_.patch1.59 KBkimberlycoy
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kimberlycoy’s picture

Title: authorized div empty when user is not logged in » authorize div empty when user is not logged in
FileSize
1.59 KB
danpros’s picture

Hi,

Yes the div is empty if user login and there is no rss feed on that page. Danland 6.x and 7.x is different since in D7 there is a toolbar at the top so I remove the login register links if user login.

I improve the layout with creating new individual wrapper for rss feed

	<?php if ($feed_icons): ?>
	<div class="feed-wrapper">
		<?php print $feed_icons; ?>
	</div>
	<?php endif; ?>

	<?php if (!$logged_in): ?>
		<div id="authorize">
      		<ul><?php global $user; if ($user->uid != 0) { print '<li class="first">' .t('Logged in as '). '<a href="' .url('user/'.$user->uid). '">' .$user->name. '</a></li>'; print '<li><a href="' .url('user/logout'). '">' .t('Logout'). '</a></li>'; } else { print '<li class="first"><a href="' .url('user'). '">' .t('Login'). '</a></li>'; print '<li><a href="' .url('user/register'). '">' .t('Register'). '</a></li>'; } ?></ul>
		</div>
	<?php endif; ?>

I'll commit this changes soon. And I did some changes to css too

#authorize { 
float: right;
margin: 5px 10px 0;
}

.feed-wrapper {
float:right;
margin-top:7px;
margin-right:20px;
}

Removing and change this ine

#authorize { <!-- I change this line -->
float: right;
padding-top: 5px;
}

#authorize a.feed-icon { <!-- I remove this line -->
padding-right: 20px;
}

Dan

cewolcott’s picture

Dan,

I am then confussed about the code. Just below the "authorize" div tag you are testing if the user is not logged in <?php if (!$logged_in): ?>, but then the next line you are testing if the $user->uid != 0 (thus logged in) and if so display "Logged in as .... | Logout" else display "Login | Register". But the "Logged in as .... " will never be displayed because of the initial test <?php if (!$logged_in): ?>.

Shouldn't you remove the <?php if (!$logged_in): ?> test so that a message is shown as to what account is logged in or if you need to Login?

Chris

danpros’s picture

Hi Cris,

Yes I know that :) that is the 6.x code. Since the d7 already has a toolbar at the top I'll remove that link when login. Next release I'll change the code like this, very simple:

	<?php if (!$logged_in): ?>
		<div id="authorize">
      		<ul><?php print '<li class="first"><a href="' .url('user'). '">' .t('Login'). '</a></li>'; print '<li><a href="' .url('user/register'). '">' .t('Register'). '</a></li>'; ?></ul>
		</div>
	<?php endif; ?>

Dan

cewolcott’s picture

Dan,

When you say "The toolbar at the top" do you mean the Administration Toolbar (Black)? Which has Hello "username" and Log out on the right? That toolbar only shows up for users with administrative permissions. Normal users do not see the black toolbar, so please leave in the "Logged in as" and "Log out" items. You could test to see if the user has admin privs and remove it, but not a big deal.

Chris

danpros’s picture

Hi Chris,

Oh my.. I did not test to login as regular user :). Okay I'll leave that and change to this (maybe):

	<?php if (!$is_admin): ?>
		<div id="authorize">
      		      <ul><?php global $user; if ($user->uid != 0) { print '<li class="first">' .t('Logged in as '). '<a href="' .url('user/'.$user->uid). '">' .$user->name. '</a></li>'; print '<li><a href="' .url('logout'). '">' .t('Logout'). '</a></li>'; } else { print '<li class="first"><a href="' .url('user'). '">' .t('Login'). '</a></li>'; print '<li><a href="' .url('user/register'). '">' .t('Register'). '</a></li>'; } ?></ul>
		</div>
	<?php endif; ?>

So if the user is admin than I'll remove that, how about that? I think that is the best solutions :)

Thanks for let me know about this.
Dan

cewolcott’s picture

That would be fine. You could also just leave it in since you will have feed icons showing on the same line and it would look a little empty without it. I have no problem showing the "Logged in as" when in admin mode. I wouldn't change the theme look just because drupal offers some wrapping around the outer edges of the theme.

danpros’s picture

Status: Active » Closed (fixed)

Hi,

I already releasing the RC version that contains this fixes. I'll close this.

Thanks,
Dan

danpros’s picture

Category: bug » task

Change it to proper category.