How can I print out a specific array entry in my template?

Moved Technical Support

Suggested Topics


  • 0 Votes
    4 Posts
    297 Views

    @dcook The color you want to change is not property of the categories, but rather the property of the theme. Black is the theme color for section categories (non-clickable link) and blue is the theme color for non-section/normal categories (clickable link).
    That's why there is no option to customize it on categories management.

    Try this:

    .title{ color: blue; }
  • 0 Votes
    4 Posts
    706 Views

    @01 "it won't open" isn't very descriptive. What is it actually doing? Screenshots are very helpful to convey that info.

    What is your nginx config? Where did you get your https certificates? Have you been following a guide, and if so, which one?

  • 0 Votes
    2 Posts
    1k Views

    Can anyone help here? I've not been able to figure anything out past this point.

  • 0 Votes
    7 Posts
    2k Views

    To restrict replies by the last reply time, you need to do two things.

    On the server side, hook into filter:topic.reply, it is passed data with the tid. Look up the last post and owner using the tid. Then, if the last post was made by the owner, and the timestamp of the last post is less then a day from now, return an error.

    On the client, you'll want to disable the reply button if the last post fulfills the same requirements above. You can use ajaxify.data to get the information you need.

    Server filter:topic.reply hook example:

    plugin.topicReply = function (data, next) { var tid = data.tid; Topics.getLatestUndeletedReply(tid, function(err, pid) { if (err) return next(null, data); Posts.getPostFields(pid, ['timestamp', 'uid'], function (err, lastPost) { if (err) return next(null, data); Topics.isOwner(tid, lastPost.uid, function (err, isOwner) { if (err) return next(null, data); if (isOwner && lastPost.timestamp + 86400000 > Date.now()) { return next(new Error('Not enough time passed.')); }else{ next(null, data); } }); }); }); });

    client.js example

    $(window).on('action:ajaxify.end', function(){ // If the user is at a page with a reply button. if ($('[component="topic/reply"]').length && ajaxify.data.posts) { var first = ajaxify.data.posts[0]; var last = ajaxify.data.posts[ajaxify.data.posts.length-1]; // If the last poster is the owner, // and they posted less than a day ago, // disable the reply button. if (last.uid === first.uid && last.timestamp + 86400000 > Date.now()) $('[component="topic/reply"]').addClass('disabled'); } });

    It's late for me, I might have messed up somewhere.

    Also, you can reduce the server code a lot by using async.waterfall and async.apply

  • 0 Votes
    10 Posts
    4k Views

    @psychobunny the thing is that a lot of controllers (e.g. users: https://github.com/FokkeZB/NodeBB/blob/patch-2/src/controllers/users.js) don't have hooks.

    Since it's Express's default behaviour to merge res.locals I wouldn't know why you shouldn't apart from that with NodeBB this will end up on the client side as well if the template will be rendered there. So yes, then maybe res.globals would make sense to allow a plugin to set global variables for all templates to receive. But then.. that wouldn't allow you to do so only for specific templates. Which again means overhead.