XF 2.3 Trending content

Since the initial release of XenForo 2.3, there has been a new system working away behind the scenes. One that some developers might have spotted but one that we hadn't actually talked about yet, because it wasn't relevant. Until now!

Let's talk about this somewhat underlying system first.

Content activity log​

This is a generic system, based on content types, which we strongly recommend you consider using for your own add-ons. Essentially what this does is keep a log of content and tracks various metrics including view counts, reaction count, reaction score and content vote counts/scores. A deeper dive into the technical bits involved in its implementation is beyond the scope of this post, but developers might want to check XF\ActivityLog\AbstractHandler, and one of the implementations for threads or posts.

You can control how long activity logs are kept for using the "Activity log length" option:

1712339680002.webp


On its own, the system doesn't do anything but let's look at how we're going to use it in XenForo 2.3.

Trending content​

Trending content is a new way for users to discover the popular content happening on your forum. We very much see this as a precursor to grander improvements to content discovery in general in the future, focusing around helping users find the content that matters; the content that is currently "hot" or otherwise popular.

1712338857154.webp


For now this is a widget that you can add wherever you want, by default we'll be adding this to the various forum overview pages including the forum list and what's new pages. But you can place yours anywhere you like. Let's take a look at the widget settings:

1712340545268.webp


Contextual content​

Trending contents are fully context aware, and you can control the behaviour of this here. For example, if the widget is enabled on a forum specific widget position, the widget can be configured to display only trending threads from this forum.

Ordering​

The two options here are "Hot" and "Top" and these decide how the results are ordered. Results which are ordered by "Hot" are more heavily weighted by how recent the content is. This is probably the best choice for busier forums.

Duration​

This is the number of days we calculate metrics over. We default this to 7 days, but you can make this as long as the value of the "Activity log length" option.

Content type​

This is where you can restrict the widget to only displaying a specific content type. By default this will be a mixed list of all content on your forum.


We also have a few options to more granularly control how trending content is calculated:

1712340182995.webp


Trending content weights​

You have full control over how the metrics from the activity log are weighted towards trending content. By default we don't include reaction count, vote count and vote score as these are less relevant for mixed content type lists. But you may choose to weight any of the metrics here more or less heavily depending on what metrics you feel are more relevant to indicate what is trending.

Trending content half life​

This is used to tweak how recency of content affects the "Hot" ordering of your trending content. After the period defined here, the weights of the activity log metrics are worth half as much.

And that's it for today. We have enabled the widget here with its default configuration and positions so you can check it out ahead of its release in Beta 4 hopefully next week.
 
The widget here has it now for sure but don't remember seeing it before. I think it's because other content could be included besides threads so they are identifying the content type.
 
So, now that I installed it on my primary location (after taking enough backups)... I just noticed how trending content appears.

Can I just have thread title Roku Data Breach instead of Thread 'Roku Data Breach'! I never noticed this here.
Can you not edit the widget template?
 
tried finding the template. failed. 2.3 seems to be doing things a bit differently. i have to find things all over again. any guidance would be helpful!
 
well... templates are not very simple from what i have seen with 2.3... everything seems to be defined elsewhere lol. if someone manages to find where the actual text is defined, that would be great. i have spent a lot of time looking for it but failed. it is probably right in front of my eyes. but i just can't find a fix for it for now. cheers.
 
Its the phrase thread_x
To expand on this a bit for non developers (I am not a teacher, so this might not make sense to some lol).

There are 3 macros in the trending_content_item_thread template, all of them call a function {{ $content.getContentTitle() }} in the Content Entity (in this case, the Thread Entity) to get the content "title".

Rich (BB code):
    <xf:extension id="title">
        <xf:extensionparent />
        <a href="{{ $content.getContentUrl() }}">{{ $content.getContentTitle() }}</a>
    </xf:extension>


Here is the function in the Thread Entity and as you can see, its passing the entity title into the phase thread_x and returning that to the template.

PHP:
    public function getContentTitle(string $context = '')
    {
        return \XF::phrase('thread_x', ['title' => $this->title]);
    }

Clear as mud? :D
 
What are the current settings on the XF for Trending Content? Just that it hasn't updated/changed in the past few days for me, and I'd expect it to be more fluid than that, if not updating hourly, at least daily?
 
It would be great if out of the box there was some kind of filter at the top of the thread list for every sub forum, where you could choose to view all trending or hot threads in that sub forum, and then filter by various date periods, similar to reddit.

That's one of the best bits of reddit, discovering a new subreddit, then looking at all the best threads from all time, the last year, last month etc.

Could definitely work nicely with specific subforums on a forum. Would be a great tool for new users to discover the best content on the site even if they're not active enough to be in What'sNew

Not sure if this new system would be a good base to add this feature?

1714156100544.webp
 
Just a thought, but isn't the "Thread" prefix at the beginning of each trending link a bit superfluous? Or is it optional/changeable?
I believe the idea is that there could be other things, like media or resources, trending, not just threads. But for a site like mine that doesn't have those, yeah, probably a bit superfluous unless it shows things like "Article". I'll see when I try it out in my dev.
 
Top Bottom