Forum Discussion

Kallie's avatar
Kallie
Guide
7 years ago

Data not displaying on custom content using LIQL

Hi, 

Very  new to Lithium Development.

I create a call to return the subject and id of messages where the board id = [my board]

In the API browser the JSON result is correct

<#assign apiVersion = "2.0"/>
<#assign x= rest(apiVersion,"/search?q=" + "SELECT id, subject FROM messages WHERE board.id = '[my board]' "?url) />
<ul>
<#list x.data.items as message >
<li>message.subject</a></li>
</#list>
</ul>

when i add the custom content to test the results only shows the following:

message.subject
message.subject
message.subject ..... (for all the items ) it does not show the subject 

I'm obviously doing something wrong, but i followed the examples on the documentation.

Thanks

  • Hi Kallie

    When you want to output a result from a Freemarker variable use ${...}.

    An example you want would be: ${message.subject}

    You may also want to add the start to your anchor tag otherwise it is malformed HTML.

  • Kallie also, in addition, you can optimise your code with the following:

    <#assign apiQuery = rest("2.0","/search?q=" + ("SELECT id, subject FROM messages WHERE board.id = '[my board]' ")?url) >
    <#list x.data.items >
    <ul>
          <#items as message>
                <li><a href="#">${message.subject}</a></li>
          </#items>
    </ul>
    </#list>

    Related links:

    Freemarker - #list | #items directive

  • Hi Kallie

    When you want to output a result from a Freemarker variable use ${...}.

    An example you want would be: ${message.subject}

    You may also want to add the start to your anchor tag otherwise it is malformed HTML.

    • Kallie's avatar
      Kallie
      Guide

      Thank You Jake!!

      Knew it was something simple: :)