1. 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"

Discussion in 'XenForo Questions and Support' started by trilogy33, Nov 15, 2011.

  1. trilogy33

    trilogy33 Well-Known Member

    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?
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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);
    	}
    }
    
     

    Attached Files:

    yavuz and trilogy33 like this.
  3. trilogy33

    trilogy33 Well-Known Member

    Thank you Jake :)
    I'll give this a go.
     
  4. trilogy33

    trilogy33 Well-Known Member

    Thanks again, superb. (y)
     
  5. Jimmy Murray

    Jimmy Murray Member

    Firstly, great work. Is it possible to omit more than one thread?
     
  6. trilogy33

    trilogy33 Well-Known Member

    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. :)
     
  7. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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);
    	}
    }
    
     
    trilogy33 likes this.
  8. trilogy33

    trilogy33 Well-Known Member

    Thank you.
    There ya go, awesome! :D
     

Share This Page