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

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
 

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:

Rich (BB 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:

Rich (BB 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']);
			}
		}
 

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.
 

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.
 
Top