is it possible to do simple calculation (addition and subtraction) inside templates.



  • is it possible to make simple calculation inside the templates?
    for example, I want the number of the replies only (not the number of posts) which means:
    number of posts -1.


  • Global Moderator

    @asma_90 it can be possible by using a helper function



  • I registered a hook, I wanto get data from the post (the data I want is post count) but somehow my function is not being fired. am I using the wrong filter ?

    "hook": "filter:post.getPostData", "method": "replynum"

    Thank you !



  • I solved my problem, but without using a helper function. here is how I solved it:
    $(window).on('action:topic.loaded', function (event, data) {
    var replynum = data.postcount - 1;
    console.log(replynum)
    });

    I have tested it and it works, every time a topic is loaded I can get the postcount.
    However, I am still unable to know why my helper function is not being executed :/


Log in to reply
 


Looks like your connection to NodeBB was lost, please wait while we try to reconnect.