Topic-icon User avatars and username position

Active Subscriptions:

None
13 years 2 months ago #32380 by Bettychung
Hi, I am not sure if I ask this question in a right place. What I am wondering is about the user avatars and username position.
When user log in can we display a small avatars and username on the top header? Something like the attached image.
File Attachment:


Thanks
The topic has been locked.
Support Specialist
13 years 2 months ago #32402 by alzander
For displaying their username, that's standard across Joomla:
$user = JFactory::getUser();
echo $user->get('username');
As for the avatar, that's a few lines of code I can provide as well. You'd need to know where you want to put it, but I'm assuming you have that covered, correct?

Let me know and I'll help with the code however we can.

Thanks,
Aex
The topic has been locked.
Active Subscriptions:

None
13 years 2 months ago #32404 by Bettychung
Thank you Alex.
But I am not sure whether I can put it on the top of the page with the template I used. If can't put it on the top can I put it on the right of the top menu bar?

Thanks!
The topic has been locked.
Support Specialist
13 years 2 months ago #32412 by alzander
You can use that code above or the code we can provide for the avatar anywhere. You just need a module to put that code in. It's up to you as to how to fit it into your existing template so that it looks right. That's not my area of expertise.

Hope that makes sense, but if not, let us know.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
13 years 2 months ago #32423 by Bettychung
Hi Alex, thank you for you explication.
You mentioned to put the code in a module, does it mean we can use a custom HTML module to do it? And then we can assign this module to the position we want, do I make sense? If this way works out, could you provide the code for me? I need both of the avatars and username.
Thank you!
The topic has been locked.
Support Specialist
13 years 2 months ago #32432 by alzander
You'd need to be able to put PHP in the module, so you'd need something like the Flexi Custom Content module, which lets you easily add Javascript, PHP or raw HTML (instead of just HTML).

With that though, you can create whatever output you'd want and then assign the module to whatever position you want.

So, I'd start with the module above (or another from that category on the JED) and start off with the following block of code and see if you like what you can do:
<div class="username">Hello <?php echo JFactory::getUser()->get('username'); ?></div>
You can change the above however you want, it's just an example of HTML and PHP in the module's output area. If you like that, let us know, and we'll get you the avatar code as well.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
13 years 1 month ago #32487 by Bettychung
Hi Alex,
Thank you for your recommendation. I installed Flexi Custom Content module, and pasted the code you provided to there. But there are 2 errors happened.
Strict Standards: Only variables should be assigned by reference in /modules/mod_flexi_customcode/tmpl/default.php on line 24

Strict Standards: Non-static method modFlexiCustomCode::parsePHPviaFile() should not be called statically in /modules/mod_flexi_customcode/tmpl/default.php on line 54
The username display normally. I am not sure if the Flexi Custom Content module has conflict with my site. Do you have any suggestion?
Thanks!
The topic has been locked.
Support Specialist
13 years 1 month ago #32498 by alzander
You have "Error Reporting" in your Joomla Global Configuration area set to "Developer". Those messages are just things that developers should be aware of to fix, but aren't causing any problems. They're also messages about Flexi Custom Content, not the PHP code you've entered.

I wouldn't worry about it and just change your error reporting to 'Maximum', if you want those details. If your site is in production, you should change it to "None" as those messages shouldn't be shown in a live environment.

Hope that helps,
Alex
The topic has been locked.
Active Subscriptions:

None
13 years 1 month ago #32510 by Bettychung
Hi Alex,
Even though I set Error Reporting to "None", the errors still there. And also I found that when I set Error Reporting to "Development" or "Maximum", there is showing another new error about JFB connect both at backend and FrontPage.
Strict Standards: Declaration of JFBConnectProfileData::bindData() should be compatible with JRegistry::bindData(&$parent, $data) in /components/com_jfbconnect/libraries/profile.php on line 357
When I set Error Reporting to "System default" the JFB connect error disappeared. I believe this would not impact JFB connect running. But the Flexi Custom Content errors never disappeared. Is better to report to Flexi Custom Content developer?

Thanks
The topic has been locked.
Support Specialist
13 years 1 month ago #32518 by alzander
The bindData strict standard message is something we need to look into, but is not something to worry about. Again, strict standards messages aren't really intended for end users, more for developers.

As for the message from Flexi Custom Content, I'm not sure why that's showing when Error Reporting is set to 'none'. It's not an issue with JFBConnect though. I'd recommend either a) contacting their developers or b) choosing another extension from the Custom Code in Modules category from the JED. I don't have any other recommendations though.

If you need anything else from us, just let us know.

Thanks,
Alex
The topic has been locked.