How to get all topics name, not only from index data?
Solved
Technical Support
-
Hello, guys!
I want create a table via widget to show all topics name from category
29
onrecent
page, to do this I'm use{{{ each topics }}}
this is work, but not what I need, with this method I get a topics name only from current page, but I need to show all topic name. How I can do it? -
API call for category 29, console.logs them in this example
fetch('https://sitename.nodebb.com/api/category/29') .then(response => response.json() ) .then(response=>{console.log(response.topics); )
To make table in widget is easy, here is example of code
<body> <table id="topicTable"> <tr> <th>Number</th> <th>Topic</th> </tr> </table> <script> const table = document.getElementById('topicTable') fetch('https://sitename.nodebb.com/api/category/11') .then(response => response.json() ) .then(response=> makeT(response.topics) ); function makeT(myTopics){ for(i=0;i<myTopics.length;i++){ const newRow = table.insertRow(); const newCell1 = newRow.insertCell(); newCell1.innerHTML = i; const newCell2 = newRow.insertCell(); newCell2.innerHTML = myTopics[i].titleRaw; } } </script> </body>
-
You can see it working here
https://aignite.nodebb.com/category/11Would be easy to add sort
-
Copyright © 2024 NodeBB | Contributors