Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Blog Author Desciption? View modes: 
User avatar
Member
Member
alexo - 2/21/2013 4:38:57 AM
   
Blog Author Desciption?
Hi all.

I have a problem and can't get the solution...

i have added a new field to the BlogPost document type called "BlogPostAutor" because the author can vary from the person which creates the document. The "Author" field uses the User-Selector control....

In my transformation i have this:
<div class="autor">
<%# GetUserAvatarImage(Eval("BlogPostAutor"), 200, 0, 0, BlogFunctions.GetUserFullName(Eval("BlogPostAutor"))) %>

<p class="autorName">
<%# BlogFunctions.GetUserFullName(Eval("BlogPostAutor")) %>
</p>

<p class="autorDescription">
??
</p>
</div>

The avatar image & the name are perfectly displayed but I also want the "User Description" to be showed, but don't know how it is done....I guess its quite easy but i can't get it...

Thank you!

best regards

User avatar
Member
Member
alexo - 2/25/2013 3:14:54 AM
   
RE:Blog Author Desciption?
Anyone an idea?!

thank you!

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 2/26/2013 12:07:05 PM
   
RE:Blog Author Desciption?
Should be able to use this code right in your transformation, assuming "BlogPostAutor" is the userid.
<script runat="server">
public string GetUserDescription(int UserID)
{
string ReturnValue = "";
CMS.SiteProvider.UserInfo ui = CMS.SiteProvider.UserInfoProvider.GetUserInfo(UserID);
if (ui != null)
{
ReturnValue = ui.UserSettings.UserDescription;
}
return ReturnValue;
}
</script>

<%# GetUserDescription(Convert.ToInt32(Eval("BlogPostAutorUserID"))) %>

User avatar
Certified Developer 13
Certified Developer 13
kentico_josefd - 2/27/2013 3:41:53 AM
   
RE:Blog Author Desciption?
Hello,

Thank you for sharing the solution, it works great. I'd just like to add that you can register custom macro if you would like to keep the code separate from transformation.

Regards,
Josef Dvorak

User avatar
Member
Member
alexo - 2/27/2013 6:00:42 AM
   
RE:Blog Author Desciption?
Thank you for the code; We already solved it using "MyFunction":
public static string getUserDescription(object userId)
{
int id = ValidationHelper .GetInteger(userId, 0);

if (id > 0)
{
string key = "TransfUserAutorDescription_" + id.ToString();

if (RequestStockHelper .Contains(key))
{
return ValidationHelper .GetString(RequestStockHelper.GetItem(key), "");
}
else
{
DataSet ds = UserInfoProvider .GetUsers("UserID = " + id, null, 1, "UserAutorDescription" );
if (!DataHelper .DataSourceIsEmpty(ds))
{
string result = HTMLHelper.HTMLEncode(ValidationHelper .GetString(ds.Tables[0].Rows[0]["UserAutorDescription"], ""));
RequestStockHelper.Add(key, result);

return result;
}
}
}
return "" ;
}

In the transformation:
<%# MyFunctions.getUserDescription(Eval("DocumentCreatedByUserID")) %>

Thanks and have a nice day