• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.0 Threads and "grep -v"

trilogy33

Well-known member
#1
Here's a weird one for you and not too sure if it's possible...

I have a "Word Association" thread going at the moment, yes the bane of servers everywhere :unsure:
Is it easy or even possible to have certain threads completely ignored by Recent Activity, so that the content doesn't show up in the results?
 

Jake Bunce

XenForo moderator
Staff member
#2
I made this addon for you. It will prevent any new feed entries being made for that thread, but it won't clear existing entries.

You need to edit this file to specify the thread_id you want to omit:

library/OmitFromRecentActivity/NewsFeedModel.php

Code:
<?php

class OmitFromRecentActivity_NewsFeedModel extends XFCP_OmitFromRecentActivity_NewsFeedModel
{
	public function publish($userId, $username, $contentType, $contentId, $action, array $extraData = null)
	{
		if ($contentType == 'post')
		{
			$postModel = XenForo_Model::create('XenForo_Model_Post');
			$post = $postModel->getPostById($contentId);

			if ($post['thread_id'] == 81)
			{
				return;
			}
		}

		parent::publish($userId, $username, $contentType, $contentId, $action, $extraData);
	}
}
 

Attachments

trilogy33

Well-known member
#6
Is it possible to omit more than one thread?
Though I personally don't need it right this second, I was thinking the same thing myself :D

This, combined with the new extra forum option features in XF1.1, specifically the:
1. "Include threads from this forum when users click "What's New?" and
2. "Count messages posted in this forum toward user total"
makes for excellent control over "game" type threads. :)
 

Jake Bunce

XenForo moderator
Staff member
#7
Firstly, great work. Is it possible to omit more than one thread?
Yes. Use this code:

library/OmitFromRecentActivity/NewsFeedModel.php

Code:
<?php

class OmitFromRecentActivity_NewsFeedModel extends XFCP_OmitFromRecentActivity_NewsFeedModel
{
	public function publish($userId, $username, $contentType, $contentId, $action, array $extraData = null)
	{
		if ($contentType == 'post')
		{
			$postModel = XenForo_Model::create('XenForo_Model_Post');
			$post = $postModel->getPostById($contentId);

			if (in_array($post['thread_id'], array(81,90,154)))
			{
				return;
			}
		}

		parent::publish($userId, $username, $contentType, $contentId, $action, $extraData);
	}
}