Forum Discussion

jmurray's avatar
jmurray
Champion
12 years ago

freemarker for user's first name / last name

Is there no way to get first name and last name via freemarker?

 

It wouldn't seem so, according to this: https://lithosphere.lithium.com/t5/developers-knowledge-base/Context-objects-for-custom-components-user/ta-p/9339

 

I may put in an idea.  Just checking to see if this is available in some way I'm unaware of first.  Thanks.

  • Even without direct access through the freemarker custom context user object, there's a vast amount of information that can be unlocked via the REST API using the rest or restadmin context objects. Details here:

    http://lithosphere.lithium.com/t5/developers-knowledge-base/Context-objects-for-custom-components-rest/ta-p/9333

     

    Here's a crude example of getting the user's first and last name, and displaying the result: 

    <#assign nameFirst = rest("/users/id/${user.id?c}/settings/name/profile.name_first").value />
    <#assign nameLast = rest("/users/id/${user.id?c}/settings/name/profile.name_last").value />
    
    Welcome ${nameFirst!""} ${nameLast!""}

     I hope this helps!

6 Replies

  • VenkS's avatar
    VenkS
    Lithium Alumni (Retired)
    12 years ago

    I don't believe this functionality is available through the freemarker "user" object.

  • djksar's avatar
    djksar
    Maven
    12 years ago
    did you eventually get an answer on this or find a workaround?
  • jmurray's avatar
    jmurray
    Champion
    12 years ago
    No, we ended up using a call that returns their username instead. It wasn't really what we wanted, but it got the job done.
  • AdamN's avatar
    AdamN
    Khoros Oracle
    12 years ago

    Even without direct access through the freemarker custom context user object, there's a vast amount of information that can be unlocked via the REST API using the rest or restadmin context objects. Details here:

    http://lithosphere.lithium.com/t5/developers-knowledge-base/Context-objects-for-custom-components-rest/ta-p/9333

     

    Here's a crude example of getting the user's first and last name, and displaying the result: 

    <#assign nameFirst = rest("/users/id/${user.id?c}/settings/name/profile.name_first").value />
    <#assign nameLast = rest("/users/id/${user.id?c}/settings/name/profile.name_last").value />
    
    Welcome ${nameFirst!""} ${nameLast!""}

     I hope this helps!

  • djksar's avatar
    djksar
    Maven
    12 years ago
    awesome! It worked. thanks for the code snippet.