Forum Discussion

alfozaav's avatar
alfozaav
Helper
2 years ago

LiQL Styling

Hi!

 

I'm creating a custom component using the LiQL 2 object reference. My goal is to fetch all messages that contain a specific tag.

I have the correct query but I donĀ“t know how to render the content using FreeMarker.

Is there a way to style it?

  • alfozaav 

    It is pretty simple. You can use below code, just need to update the Query in first line. 

     

    <#attempt>
    <#assign messageList =  rest("2.0","/search?q="+"QUERY"?url).data.items/>
    <#list messageList as messageItem>
       <p>messageItem.subject </p>
    </#list>
    <#recover>
    <!--message listing component not working-->
    </#attempt>

     

     

  • alfozaav 

    It is pretty simple. You can use below code, just need to update the Query in first line. 

     

    <#attempt>
    <#assign messageList =  rest("2.0","/search?q="+"QUERY"?url).data.items/>
    <#list messageList as messageItem>
       <p>messageItem.subject </p>
    </#list>
    <#recover>
    <!--message listing component not working-->
    </#attempt>

     

     

  • Thank you for your answer Vikas, but I'm still having problems.

     

    This is my code:

    <#assign apiVersion = "2.0" />
    <#assign QUERY = "SELECT * FROM messages WHERE tags.text = 'F5 XC'" />
    <#assign messageList = rest(apiVersion, "/search?q=" + QUERY?url).data.items />
    
    <section>
        <h1 style="color: red;">Message List Component</h1>
    
        <#list messageList as messageItem>
            <h2 style="color: green;">${messageItem.subject}</h2>
            <p>${messageItem.body}</p>
        </#list>
    </section>

    This is the result:

    I'm getting in the body html tags as strings, so my question is how can I use the response or how can I render the message body properly?