Trending Content: Option to exclude nodes from trending content

VBX Co

Well-known member
We'd like an option to exclude nodes/forums from trending content.

Our off-topic forums are busy, but they are for members to chat and waffle and we don't need the busy game/quiz threads popping up in trending content all the time, especially as they're of no interest to the on-topic crowd or guests/potential new members. We also have personal and financial member-only sections that we wouldn't want featured in trending content either, so an option to exclude would be cool. 😎

Thanks
 
Upvote 61
Is this template modification excludes media and resource content from the widget?
I do not have XFMG/XFRM set up to combine trending content in a widget to give you an answer or work something out that works.

The solution there works on 2.3.3 with trending content that are threads from the main forum though.
 
Minor tweak for now:
Edit template widget_trending_content.

Find
HTML:
                    <xf:foreach loop="$content" value="$item">

There should be three of them as there are three styles for this widget. In my example, I am only doing it for the first one, simple, that shows in the sidebar. But, you can do it to all 3 or whichever you use.

Put in a new line:
HTML:
<xf:if is = "!in_array($item.node_id, [3, 18])">

Replace 3 and 18 with a digit (node id) or comma-separated digits (node ids) as shown.

After that and before the next </xf:foreach> place in </xf:if>.

Since I am ignoring content from nodes 3 and 18, only 1 item will appear.

View attachment 312241

So, I can do one of two things: 1) allow only 1 item to show up, or 2) edit the widget and crank up the maximum entries to 15.

View attachment 312242

I emphasize "Simple" as I didn't edit all three loops, just the simple one that will be displayed in the sidebar for this demonstration.

And the results will be similar to when I just had it showing 5:

View attachment 312243

The problem with this method is that you'll need to adjust the maximum entries if it jumps up too high (a list of 10) or goes down too low (a list of 3).

However, it's a quick patch until there's a widget preference for excluding nodes.
This is a nice modification. It also makes me wonder if I can figure out a way to count the number of trending items per forum, and use some sort of counting loop to limit them to display (for example) only three (or some other number) items.
 
This is a nice modification. It also makes me wonder if I can figure out a way to count the number of trending items per forum, and use some sort of counting loop to limit them to display (for example) only three (or some other number) items.
This is what I privately discussed with the OP. I am copy/pasting over what I think might work, so that you can set the maximum to display, say, 100, but it only ever display 5.
HTML:
                    <xf:foreach loop="$content" value="$item">
<xf:if is="{{ $content <= 5 }}">
                        <li class="block-row">
                            {{ $result.renderContent($item, 'simple', $snippetLength)|raw }}
                        </li>
</xf:if>
                    </xf:foreach>

I don't know the values of $content or $item to see if there's an integer that can be used and then limit it to 5 or fewer items no matter what you have set for the widget to display. Someone would have to let me on their dev to mess with the template to do a {{ dump($content) }} or {{ dump($item) }} in the right places to determine if there's an integer, to begin with, and if there is, if the if statement would work with that.

But, I haven't tested it (or have XFRM/XFMG to also include those in the widget to test).

Might also be able to do something like this at the beginning of the loop:
HTML:
<xf:set var="$num" value="1" />

At the end of the loop:
HTML:
<xf:set var="$num" value="{{ $num + 1 }}" />

Then an if statement of $num <= 5.

Like:
HTML:
<xf:set var="$num" value="1" />
                    <xf:foreach loop="$content" value="$item">
<xf:if is="{{ $num <= 5 }}">
                        <li class="block-row">
                            {{ $result.renderContent($item, 'simple', $snippetLength)|raw }}
                        </li>
<xf:set var="$num" value="{{ $num + 1 }}" />
</xf:if>
                    </xf:foreach>
 
Last edited:
We have a G&N section that is only visible to logged-in members and is excluded from What's New and other widgets we use on the Homepage. It would be really bad if we can't exclude it from Trending Content, especially since the G&N forum sees a lot of traffic.

And I don't want to have to start messing with templates to make this possible. It shouldn't be necessary. We should be able to set a "forum limit" in the widget itself, the way it is done in other widgets like What's New, New Posts etc.
 
Maybe also have "sponsored" threads as well.
Where a forum sponsor can get an item in the trending content.
If we wanted to make money, sure. But we decided from the start that we would keep the site free for everyone (although there is a threshold for the G&N forum. And for our marketplace as well). We also don't have ads.

Having said that, I agree that more options are good.
 


Write your reply...
Back
Top Bottom