By Josh Lewis on Sunday, 25 May 2014
Posted in General Issues
Replies 14
Likes 0
Views 1.5K
Votes 0
ES's modules don't quite display the username how I want it to display (but it does come incredibly close). I'm wanting to display my avatar next to my username very similarly to the ES drop down menu. In my case I want the avatar and the profile pic to link to the user's profile rather than a drop down menu. Another module sorta did this but didn't have as good of formatting and the profile pic did not link to the users profile.

From what I've gathered the stacked team is probably too busy to change some display settings to the module. Assuming that's true, what is the PHP code for displaying the avatar and the user profile? I'm not savvy at all with PHP, I made an attempt with the following codes:

<img src="<?php echo $my->getAvatar( SOCIAL_AVATAR_MEDIUM );?>" alt="<?php echo $modules->html( 'string.escape' , $my->getName() );?>" />

<a href="<?php echo $my->getPermalink();?>" class="user-name-link"><?php echo $my->getName();?></a>


Depending on how I went about it, the code either didn't work or would make the page go blank. Right now I'm in the process of re-doing some of my site's layout to make things as easy as possible for my users.
Hello Josh,

Based on what you already have, if you want to use Yasser's code above, you need to use <?php echo $my->getPermalink(); ?> instead
·
Friday, 30 May 2014 11:35
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Josh,

Since we are on Twitter Bootstrap 3, most of the classes are available for you. You can learn more about Twitter Bootstrap 3 here, http://getbootstrap.com/ . If you want the avatar to appear side by side the name, you could use media objects


<div id="fd" class="es">
<div class="media">
<div class="media-object pull-left"><img src=".." /></div>
<div class="media-body">Name</div>
</div>
</div>


The outer wrapper is required so that the module will inherit twitter bootstrap's styling from EasySocial.
·
Sunday, 25 May 2014 13:26
·
0 Likes
·
0 Votes
·
0 Comments
·
I appreciate the tips on bootstrap. But again, I'm a complete PHP noob. I tried putting my code in the code you provided which resulted in a blank page (to be expected). Because I'm putting the code in a some what crammed spot, I think it's best for me to code my own layout and use my own padding rules so that it doesn't bump the other objects around (the module certainly did which I tried many tricks which got very messy).

So outside of styling, what is the PHP code to call the image and user name? What I want to do is wrap the username text and the image within a anchor so that it's one single "button". This way when someone hovers over any part of it, the background highlights to the exact same color as my user menu.
·
Sunday, 25 May 2014 17:40
·
0 Likes
·
0 Votes
·
0 Comments
·
it also depends where you want to use this, on an existing ES page you can make this happen without php code. on all other or in all other components or joomla environments you have to follow this guide to hook in the right php functionality:
http://docs.stackideas.com/developers/users/users
·
Sunday, 25 May 2014 18:03
·
0 Likes
·
0 Votes
·
0 Comments
·
Hm, the codes above is actually not php codes. They are just plain html codes only
·
Monday, 26 May 2014 03:21
·
0 Likes
·
0 Votes
·
0 Comments
·
@Noobster, thanks for the link. That brought me part way.

@Mark, I know. I was going on a whim hoping that wrapping it in those HTML elements would make it work some how. I've seen some crazy stuff happen with stuff you wouldn't expect to fix a problem. So here is what I have so far:

<?php echo Foundry::user()->getName(); ?>

<?php $my = Foundry::user(); ?>

<img src="<?php $my->getAvatar(); ?>" />


(be sure to go to edit mode of this post to see the code, EasyDiscuss is breaking some of it)

It displays the username, but the avatar does not display (it shows a broken image). So now I need two things:

1. The proper PHP code to display the avatar.

2. The PHP code to link to the user's permalink so that I can wrap both objects within that anchor.
·
Monday, 26 May 2014 04:25
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Josh,

You are missing an "echo" for the image part
·
Monday, 26 May 2014 10:57
·
0 Likes
·
0 Votes
·
0 Comments
·
Thanks Mark, that did the trick. I actually know enough PHP to have known better. It's been a while.

Anyways, how do I retrieve the permalink of a user? (if non is selected, then their user name with the id) I know how to link to site/profile which works, but I want to create a link that uses site/profile/username. This way when the user shares a link to their profile they are not linking to the profile menu item.
·
Friday, 30 May 2014 09:35
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Josh,

I am sorry, but I cannot understand what do you mean by:
if non is selected, then their user name with the id

By the way, for profile permalink you can retrieve by clicking the username displayed. Perhaps you can tell us what do trying to achieve here so that we can assist you. You can also try use this code
<?php echo $user->getPermalink();?>
and see how it goes.

If you have anymore question, please don't hesitate to ask us.
Please be advise.
Thanks.
·
Friday, 30 May 2014 11:01
·
0 Likes
·
0 Votes
·
0 Comments
·
Some users set up a permalink and others do not. For example my profile uses a permalink: http://www.alpineascent.com/profile/josh
Sean however does not: http://www.alpineascent.com/profile/93-sean

As a result I cannot assume the user has a permalink. Currently my code looks like this:

<a href="profile">

<?php $my = Foundry::user(); ?>
<img src="<?php echo $my->getAvatar(SOCIAL_AVATAR_SMALL); ?>" /> <?php echo Foundry::user()->getName(); ?></a>


I tried the code you mentioned above, but unfortunately it brings up a blank white page. If I combine it with my code above the page is almost blank except for the avatar and the username. I'm trying to get both the username and the avatar be apart of a single link that goes to their profile page. I can do this easily with a menu item, but I have yet to figure this out with code.
·
Friday, 30 May 2014 11:27
·
0 Likes
·
0 Votes
·
0 Comments
·
Awesome, thanks Mark. BTW, why do you lock threads after the issue is resolved? I have one very recent case where I was pretty comfortable with the answer but realized something needed to be adjusted with the help of the stacked team. It's a minor issue (non error related) that can be resolved later. This results in more threads needing to be creating when the subject needs to be brought back due to something unexpected. In my case I would probably just post a support ticket.
·
Friday, 30 May 2014 12:07
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Josh,

Yeah, we're actually considering not locking the threads but there's this issue currently because sometimes the thread wasn't followed by me or replied by me so when there's nobody replied to the thread, I wouldn't be able to know. Hence, we wanted to try to keep the discussion 1 to 1 to avoid people complaining "you did not reply to me"

However, Jensen brought up something internally that we should leave the forums as is so that everyone in the community could end up with an open ended-ish discussion and I think that makes perfect sense too. Will see what we can do about it since we have already implemented "Send a nudge" if you didn't get a reply.
·
Friday, 30 May 2014 13:13
·
0 Likes
·
0 Votes
·
0 Comments
·
Jensen voiced exactly what my main reason for leaving it open ended. I wasn't sure if a separate discussion was preferred.

As for the nudge feature, certainly a good idea.
·
Friday, 30 May 2014 15:21
·
0 Likes
·
0 Votes
·
0 Comments
·
Noted, thanks for the heads up on this
·
Saturday, 31 May 2014 00:46
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post