|
| Displaying Extended Attributes in Skins |
 |
Thu, 21 Sep 2006 14:57:07 +000 |
I've added an extended attribute called FriendlyGroupName. I have it displayed
in View-PostFlatView.ascx:<asp:literal runat="server"
id="Literal9" text='<%# Users.GetUser(0,
(string)DataBinder.Eval(Container.DataItem, "Username"), false,
true).GetExtendedAttribute("FriendlyGroupName") %>' />
This worked in View-PostFlatPreview.ascx as well. However, when I tried to drop
it into View-SinglePostViewInThreadedView.ascx and View-SinglePostView.ascx, it
blew up (same error for both):
-------------
From Jose Lema:
The reason you're getting that error is due to the fact that those two skins
expect only a single post, not a collection of posts. As such, the container is
not a repeater, so there is no "DataItem". In looking at the code, it
appears we didn't make it too easy to add what you desire. There's no read
access to the controls User object. To work around it, I suggest you
"grab" the user from any of the user-related controls and use it to
bind your new literal. (In my sample below, I used the JoinedAttribute, but you
could use any of the controls that expose a public User property).
So, for example, you could add the following to the skin:
<asp:literal id="Literal9" runat="server" />
And add the following to an inline code section:
<script language="cs" runat="server">
void Page_Load()
{
Literal9.Text =
JoinedAttribute.User.GetExtendedAttribute("FriendlyGroupName");
}
</script>
Hope that helps.José
|
| Post Reply
|
|
|
|
|
|
|
|
|
|