Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Gary Cheetham 20 posts 144 karma points
    Feb 22, 2016 @ 18:50
    Gary Cheetham
    0

    Adding Extra Authorship/Creator Properties

    Hi,

    I want to add detailed author (creator) information to blog post templates.

    Right now I can do things like

    Model.Content.CreatorId
    Model.Content.CreatorName
    

    But I'd like to do things like:

    Model.Content.CreatorEmail
    Model.Content.Creator.GetPropertyValue<string>("creatorBio")
    

    My content creators are backoffice users, not members.

    What's the recommended way to achieve accessing extra properties for my content creators?

    Thanks in advance, Gary

  • Barry Fogarty 493 posts 1129 karma points
    Feb 22, 2016 @ 20:43
    Barry Fogarty
    1

    You would be best off using nodes in the content section for this information, as it is intended for use on the frontend of the site. That way you have full control of the information.

    You could have a content picker on your blog post document type to select the Author node, or if you want to get fancy you could wire up an event handler for the ContentService_Created event and check the UmbracoContext.Current.Security.CurrentUser property to look up the appropriate content node.

    You should check out Shannon's Articulate blog package for inspiration:

    https://github.com/Shazwazza/Articulate/

    He accesses the current Umbraco user in the aforementioned event to populate an Author field on the blog post nodes. That value is then used to lookup Author metadata for the front end.

    https://github.com/Shazwazza/Articulate/blob/7ee1e41e3cea38432cdc624ca8259a60a43501b2/src/Articulate/UmbracoEventHandler.cs

  • Barry Fogarty 493 posts 1129 karma points
    Feb 22, 2016 @ 20:49
    Barry Fogarty
    1

    Also FYI There is a User Picker datatype - if you have a User Picker property on your Author node, you could look up the correct node where its value equals the UmbracoContext.Current.Security.CurrentUser.Id in your ContentService_Created event.

Please Sign in or register to post replies

Write your reply to:

Draft