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

XF 1.1 Is it possible to exclude forum rooms from the RSS feed?

Discussion in 'XenForo Questions and Support' started by System0, Jun 17, 2012.

  1. System0

    System0 Active Member

    As per this thread.

    I use the RSS feed to update Twitter and Facebook though I don't want threads from certain rooms to be included in the feed. Specifically, the off topic discussion rooms such as general chat and feedback etc.

    Is there a way to include them from the RSS feed but ensure they are still shown in the new posts list etc on the forums?

    Kevin
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Requires custom code. Here is a quick hack for you:

    library/XenForo/ControllerPublic/Forum.php

    Add the red code and specify the excluded node_ids in blue:

    Code:
    	public function getGlobalForumRss()
    	{
    		$threadModel = $this->_getThreadModel();
    		$visitor = XenForo_Visitor::getInstance();
    
    		$threadsPerPage = max(1, XenForo_Application::get('options')->discussionsPerPage);
    		$autoReadDate = XenForo_Application::$time - (XenForo_Application::get('options')->readMarkingDataLifetime * 86400);
    
    		$threads = $threadModel->getThreads(
    			array('find_new' => true, 'last_post_date' => array('>', $autoReadDate), 'node_id' => array(2,26), 'not_node_id' => true),
    			array(
    				'limit' => $threadsPerPage * 3, // to filter
    				'order' => 'last_post_date',
    				'join' =>
    					XenForo_Model_Thread::FETCH_FORUM | XenForo_Model_Thread::FETCH_FORUM_OPTIONS |
    					XenForo_Model_Thread::FETCH_USER,
    				'permissionCombinationId' => $visitor['permission_combination_id']
    			)
    		);
    		foreach ($threads AS $key => $thread)
    		{
    			$thread['permissions'] = XenForo_Permission::unserializePermissions($thread['node_permission_cache']);
    
    			if (!$threadModel->canViewThreadAndContainer($thread, $thread, $null, $thread['permissions']))
    			{
    				unset($threads[$key]);
    			}
    		}
    		$threads = array_slice($threads, 0, $threadsPerPage, true);
    
    		$viewParams = array(
    			'threads' => $threads
    		);
    		return $this->responseView('XenForo_ViewPublic_Forum_GlobalRss', '', $viewParams);
    	}
    
    library/XenForo/Model/Thread.php

    Add the red code:

    Code:
    	public function prepareThreadConditions(array $conditions, array &$fetchOptions)
    	{
    		$sqlConditions = array();
    		$db = $this->_getDb();
    
    		if (!empty($conditions['forum_id']) && empty($conditions['node_id']))
    		{
    			$conditions['node_id'] = $conditions['forum_id'];
    		}
    
    		if (!empty($conditions['node_id']))
    		{
    			if (is_array($conditions['node_id']))
    			{
    				$sqlConditions[] = 'thread.node_id ' . (!empty($conditions['not_node_id']) ? 'NOT ' : '') . 'IN (' . $db->quote($conditions['node_id']) . ')';
    			}
    			else
    			{
    				$sqlConditions[] = 'thread.node_id ' . (!empty($conditions['not_node_id']) ? '!' : '') . '= ' . $db->quote($conditions['node_id']);
    			}
    		}
    
     
    BassMan, polle, System0 and 1 other person like this.
  3. System0

    System0 Active Member

    Thanks Jake. You're a star. It worked like a charm. Would love to see this integrated into the core or released as an add on.
     
  4. polle

    polle Active Member

    Perfect and yes, this should be included into the core to just select whats needed in the admin.
     
    BassMan likes this.
  5. BassMan

    BassMan Well-Known Member

    Excellent! Works like a charm on XF 1.2.2. Just what I needed. And it should be in the core.
     
  6. polle

    polle Active Member

    Does this work in XenForo 1.3.4 ?
     
  7. polle

    polle Active Member

    This works in XenForo 1.4.7 ?
     

Share This Page