MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

How to view Name and Surname instead of the username  (Mono Support )

Viewed 17035 time(s), 6 post(s) 1/28/2013 3:37:21 PMby afabri73
afabri73

afabri73

1/28/2013 3:37:21 PM
Hi,
there is a way to view (in all pages that it appears) the name of the users instead of the username.

For example.
17 minute(s) ago by username
Last post ... Posted by username 17 minute(s) ago

become:


17 minute(s) ago by Name Surname
Last post ... Posted by Name Surname 17 minute(s) ago

This content has not been rated yet. 
115 Reputation 19 Total posts
pajo

pajo

1/29/2013 11:21:35 AM
From version 4.7 if user has first and last name entered it should display full name, otherwise it will display username in most modules, but there are some that will still show username and there is no central point where you can change this. Can you tell us what version of MonoX you're using and where you're having problems with display name and I'll see what would be easiest way to change this. In case module is using templates, you can change template to show display name and if you're not that lucky you would need to get dirty and extend controls.
This content has not been rated yet. 
629 Reputation 83 Total posts
afabri73

afabri73

1/29/2013 11:46:48 AM
Thank you,
we are using Monox v4.5.32xx (now I am not in the office)

I look forward to your reply
Best reguard
Adriano
This content has not been rated yet. 
115 Reputation 19 Total posts
pajo

pajo

1/29/2013 1:17:16 PM
Are you able to upgrade MonoX to version v4.7, in the version you're using this will be much harder to achive?
This content has not been rated yet. 
629 Reputation 83 Total posts
afabri73

afabri73

1/29/2013 1:48:30 PM
I know...but at the moment it is impossible to upgrade to the newer version

This content has not been rated yet. 
115 Reputation 19 Total posts
pajo

pajo

1/30/2013 10:35:04 AM
Ok,

Here is a general idea. In case of templates you can access original entity used for binding through $Container.DataItem. First you can try to replace username with $Container.DataItem.AspnetUser.UserDisplayName. There is no guarantee user profile will be fetched and in that case you need to extend webpart and replace username with your display name. You can find basic steps for extending webparts in this blog. Once you extend easiest way is to override ParseTemplateTags, find username tag used in template and replace value with your display name.

protected override Hashtable ParseTemplateTags(BlogEntity blog)
{
  var tags = base.ParseTemplateTags(blog);
  tags["<# UserName #>"] = UserProfileBLL.GetInstance().GetCachedUserProfile(blog.UserId).UserDisplayName;
  return tags;
}
When having small active user base (around 100 users) caching will work just fine, in case of larger user base you should consider fetching profiles from database in that case you would need to override BindData to get list of user ids and fetch their user profiles from db and use this list inside ParseTemplateTags.

When you have extended webpart you must replace MonoX webpart with your own on your pages and that should be it.
This content has not been rated yet. 
629 Reputation 83 Total posts