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 REST api to call out the categories. I'm using the one below:
<assign# topics= rest("/categories/id/blog_topics/boards").messages />
Can someone explain to me what the .messages does? Or if I change to .title? - After this,
I'm trying to get the categories title to display as links. Doing something like the below
<a href=“${category.message.@href}”> ${category.message.subject}</a>
This was an example I grabbed from here
This is the one I'm trying to semi-follow but can't seem to make it possible for my community.
And direction/tips would be great !
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>