Forum Discussion

maxwelldhsu's avatar
8 years ago

Dynamic navigation menu and next steps

I'm trying to create a dynamic menu based on categories. The categories will serve as main topics, which you can then click into to show the blog articles.    First step, I know I need to use a RES...
  • TariqHussain's avatar
    8 years ago

    maxwelldhsu - You are using the wrong call to fetch the categories. 

     

    To fetch the categories use the below calls. 

    <#assign Categories = rest("/categories/nested").categories/>

    https://community.lithium.com/restapi/vc/categories/nested

     

    <#assign topics= rest("/categories/id/blog_topics/boards").messages /> is key here which is returned in xml response and .title will not work there.  In the link you have mentioned, they are fethcing the messages for the boards call .messages will produce error. 

     

    <#assign boards = rest("/boards/nested").boards /> 

    https://community.lithium.com/restapi/vc/boards/nested

    e.g for the board call below is the response 

     
    <response status="success">
    <boards>
      <board type="board" href="/blogs/id/socialmediablog">
      <interaction_style type="string">blog</interaction_style>
      <user_created type="boolean">false</user_created>
      <blog type="boolean">true</blog>
      <id type="string">socialmediablog</id>
      <owner type="user" null="true"/>
      <short_title type="string">Social Media Management Blog</short_title>
      <title type="string">Social Media Management Blog</title>
      <description type="string">
      Home to best practices, success stories and product roll-outs for Lithium Social Media Management.
      </description>
     </board>
      .....

    In order to access the title of the board, you have to loop through all the boards with #list. You can not access the title key directly. 

    <#assign boards = rest("/boards/nested").boards /> 

    <#list boards.board as board>

    ${board.title}

    </#list>