XF 2.2 threads/replies count on widget new_post

Nicolas FR

Well-known member
Hello,

I mainly use the new_post widgets on my home page (forum_list), the classic forums are not displayed (display: none; with media-queries).
I would like to display the threads and replies count of each forum on the corresponding widget (1 forum = 1 new_post widget).

Is this possible?
Which $variable i have to use ?

Many thanks ! :)
 
Thanks @Brogan,

So now i can identify variables, in my case i need : discussion_count and message_count.

Well, if i want to display those count in the new messages widget how can i do ?
I tried {{ dump($discussion_count) }} in the widget_new_posts template but it return null.
HTML:
<h3 class="block-header">
    <a href="{$link}" rel="nofollow">{$title}</a>
    {{ dump($discussion_count)}}
</h3>

Capture d’écran 2021-02-18 204956.png

maybe i have to link this $variable to the concerned node selected in the widget. But how can i do that ?
node id is 2 and widget id is 1

Thanks.
 
eg: I create a new widget to display new posts relative to node id=2
So in the block-header of the widget i would like to display the discussion count of the node id=2 near the widget title.

So if in node 2 i have 12 threads i want the widget block-header display title and count :
NEW POST WIDGET NODE 2 TITLE ------------ THREADS : 12

As i don't unerstand very well how all this works it's difficult for me to explain well...
 
Ok i understand now.
In my case widgets are displayed on home page not in the node page concerned by the widget.
That's why i think i need to specify which node is concerned in the variable

something like $context.node-id2.discussion_count (totally invented)
 
I don't know if i understand well but i did this
create a HTML widget and put only this inside {{ dump($discussion_count) }}, i put it on forum home under nodes and the widget return null.
 
create a HTML widget and put only this inside {{ dump($discussion_count) }}, i put it on forum home under nodes and the widget return null.

The var would never be in that format in this case it would be $context.forum.discussion_count.

However, I can tell you now there isn't one natively available for the discussion and message counts for every forum.

You can possibly pass them as vars to make them available globally.
 
You can possibly pass them as vars to make them available globally.
Ok, $discussion_count are originaly in node_list_forum template right ?
so in the first line i wrote <xf:page option="thread_count">{$discussion_count}</xf:page>
nb: i saw in this template this variable $extras.discussion_count :unsure:
HTML:
<xf:if is="!{$extras.privateInfo}">
    <div class="node-statsMeta">
        <dl class="pairs pairs--inline">
            <dt>{{ phrase('threads') }}</dt>
            <dd>{$extras.discussion_count|number_short(1)}</dd>
        </dl>
        <dl class="pairs pairs--inline">
            <dt>{{ phrase('messages') }}</dt>
            <dd>{$extras.message_count|number_short(1)}</dd>
        </dl>
    </div>
</xf:if>

So now i can use $context.forum.thread_count everywhere ?
I try but........ no success
 
Top Bottom