XF 2.2 Any reason why count($xf.vars.posts) > 10 would not work in thread_view sidebar widget?

Stuart Wright

Well-known member
With count($xf.vars.posts) > 10 in the display condition, even if I use 1 instead of 10, the widget does not show in thread_view.
If I empty the display condition field, the widget shows.
What am I missing please?
1616958306641.webp
Thanks.
 
Where did you get $xf.vars.posts from?

The correct code is $context.thread.reply_count, used like so: $context.thread.reply_count > 9.
 
Where did you get $xf.vars.posts from?

The correct code is $context.thread.reply_count, used like so: $context.thread.reply_count > 9.
Thanks, Brogan. I got $xf.vars.posts a long time ago. Can't remember where, exactly. Might have been advice from @Chris D for Xenforo 1.
What I'm after is the number of posts on the page, so that a widget only displays on pages that are long enough. Which is what I thought $xf.vars.posts gave me.
If with 30 posts per page, you have 34 replies, then on the first page, you can have more widgets because there are 30 posts on it, but on page 2, you'll only have 5. So $context.thread.reply_count won't help me. Which is where I thought the post count on the page was the solution.
If $xf.vars.posts doesn't work, is there a solution?
 
Last edited:
Top Bottom