Forum Discussion

ethanede's avatar
ethanede
Helper
7 years ago

Translate Freemarker to LiQL query?

Hello all, First time poster, new to Lithium, this is probably pretty basic, please be gentle. I did some searching but couldn't find anything directly addressing this question. Is it possible to c...
  • Parshant's avatar
    Parshant
    7 years ago

    ethanede

    If the page is associated with a user, then "context.user" returns a user context object, otherwise returns null.

    ${page.context.user.id}


    You can chain calls on the user object from this method. We can use this in MyProfilePage (only when an admin is editing another user's profile.) and ViewProfilePage on viewign other's profile information.

    <#assign page_user_id = page.context.user.id />
    <#assign custom-profile-field = profile.agent_id />

    Using V1:

    <#if page_user_id??>
      <#assign allowed=rest("/users/id/${page_user_id?c}/profiles/name/${custom-profile-field}/allowed").value />
      <#if allowed?trim == "true">
          <#assign value = rest("/users/id/${page_user_id}/profiles/name/${custom-profile-field}").value />
          <span>${value?string}</span>
      </#if>
    </#if>

    Using V2:

    Select * from users where id='${page_user_id?c}'