Forum Discussion

Inactive User's avatar
Inactive User
13 years ago

Editing Blog Component

(Assuming we have already had added to our environment a custom profile field, location)... On a blog post, is there a way to add a profile field's information (such as location) to the line displaying the author username/date authored?

 

I know the line is editable using Toolbelt, but if its possible, would like to know what the syntax would be to add information from the profile there. 

 

Thanks in advance for your help!

  • AdamN's avatar
    AdamN
    13 years ago

    Unfortunately you're not going to be able to accomplish this with a text change alone, since this type of customization requires pulling in dynamic content. You'll need a custom component for retreiving the user's profile location, and then displaying the content. This custom component will replace the "message-header' component on the "Blog Message" page. Because the "message-header" contains a few different elements (such as the author info, date, and subject), you'll need to account for those as well.

     

    This is a very crude example component, but hopefully will get you started in the right direction:

    <#assign userLocation = rest("/users/id/${env.context.message.author.id?c}/profiles/name/userlocation").value />
    
    <@component id="subject" />
    <@component id="author" />
    | ${userLocation} |
    <@component id="post-date" />

     This doesn't have any error handling for the REST API call, so that may be something you'd want to add in. You may also need to use "restadmin" instead of "rest" depending on the permissions of that particular custom profile field. Some text string changes may needed as well get the exact result you're looking for.

     

    I hope this helps!

     

     

     

     

11 Replies

  • AdamN's avatar
    AdamN
    Khoros Oracle
    13 years ago

    This may not necessarily be exhaustive, but I know that all of these work for the "BlogMessage" page:

     

        <component id="subject"/>
        <component id="author"/>
        <component id="post-date"/>
        <component id="last-edited"/>
        <component id="body"/>
        <component id="source-device"/>
        <component id="labels"/>
        <component id="kudos"/>
        <component id="actions"/>

     

    Regarding removing message-header, you can always go back to the page editor in Studio and add it back if needed.