Here's my scenario:
Author Picker
to the default umbBlogPost
(from the blog4umbraco package) which gives me access to the author's id in an XSLT macroAuthor Picker
is pulling up a list of umbraco users, not membersI've tried several different ways based on Google searches which all seem to be using the Membership API, such as umbraco.libary:GetMember
and umbraco.library:GetMemberName
which is not working, again, as I am dealing with umbraco users, not members. There doesn't appear to be any user equivalent methods, i.e., umbraco.libary:GetUser
or umbraco.library:GetUserName
.
Does anyone know how I can get user properties in an xslt macro? I am using version 4.7.2. Also, while I'm currently working with xslt, if this can be done with a Razor macro (if supported in 4.7.2?) I am open to seeing this approach as well. Thanks.
I ended up solving this by writing a Razor macro. The key was to add @using umbraco.BusinessLogic;
at the beginning of the macro. This namespace provides the API required to get user data as opposed to member data.
For anyone interested, here's the macro I wrote:
@using umbraco.BusinessLogic;
@inherits umbraco.MacroEngines.DynamicNodeContext
<div>
<h1>
From Our Blog
</h1>
<ul>
@foreach(var i in @Model.AncestorOrSelf("umbHomepage").Descendants("umbBlogPost").OrderBy("PostDate desc").Take(5))
{
<li>
<p>
<a href="@i.NiceUrl" title="@i.Name">@i.Name</a><br />
by <a href="#">@umbraco.BusinessLogic.User.GetUser(Int32.Parse(i.blogAuthor)).Name</a> on @i.PostDate.ToString("MMM dd, yyyy")
</p>
</li>
}
</ul>
</div>