Script to display all posts by _id
-
I have a custom route with custom template. I have a list of post _id's that I need to be displayed on this custom template. Pretty much like how it looks when you filter by tag.
Very new to nodebb, please point me to the right direction how I can query posts by _id and pass it to be displayed on template.
-
Posts.getPostsData
NodeBB/src/posts/data.js at 4c66c7f9b2be220305aac47208c87d29d6b9502f · NodeBB/NodeBB
Node.js based forum software built for the modern web - NodeBB/src/posts/data.js at 4c66c7f9b2be220305aac47208c87d29d6b9502f · NodeBB/NodeBB
GitHub (github.com)
-
@pitaj excuse my ignorance, But how would I use this?
I've tried
function testrender(req, res, next) { const Posts = require('../../src/posts/data.js'); var postid = '60617ae45d48fbb848f496aa'; res.render('test321', { uid: Posts.Posts.getPostData(postid) }); };
But I get error "Cannot read property 'getPostData' of undefined" ?
-
@ape the standard way to get nodebb modules is
require.main.require
const Posts = require.main.require('./src/posts'); Posts.getPostData(pid, callback)
Copyright © 2024 NodeBB | Contributors