Account Settings Sidebar in Conversations?

DRE

Well-known member
What's the best way to add the account settings wrapper in conversations?

Our emails have a sidebar, why not conversations?
 
It's not hard, but it does require several edits:

library/XenForo/ControllerPublic/Conversation.php

Add the red code (comment old return, add new one):

Rich (BB code):
	public function actionIndex()
	{
		$conversationId = $this->_input->filterSingle('conversation_id', XenForo_Input::UINT);
		if ($conversationId)
		{
			return $this->responseReroute(__CLASS__, 'view');
		}

		$visitor = XenForo_Visitor::getInstance();
		$conversationModel = $this->_getConversationModel();

		$conditions = $this->_getListConditions();
		$fetchOptions = $this->_getListFetchOptions();

		$totalConversations = $conversationModel->countConversationsForUser($visitor['user_id'], $conditions);

		$conversations = $conversationModel->getConversationsForUser($visitor['user_id'], $conditions, $fetchOptions);
		$conversations = $conversationModel->prepareConversations($conversations);

		$viewParams = array(
			'conversations' => $conversations,
			'page' => $fetchOptions['page'],
			'conversationsPerPage' => $fetchOptions['perPage'],
			'totalConversations' => $totalConversations,

			'ignoredNames' => $this->_getIgnoredContentUserNames($conversations),

			'canStartConversation' => $conversationModel->canStartConversations(),

			'search_type' => $conditions['search_type'],
			'search_user' => $conditions['search_user'],

			'pageNavParams' => array(
				'search_type' => ($conditions['search_type'] ? $conditions['search_type'] : false),
				'search_user' => ($conditions['search_user'] ? $conditions['search_user'] : false),
			),
		);

		// return $this->responseView('XenForo_ViewPublic_Conversation_List', 'conversation_list', $viewParams);

		return $this->_getWrapper(
			'conversations', 'view',
			$this->responseView('XenForo_ViewPublic_Conversation_List', 'conversation_list', $viewParams)
		);
	}

This change must be applied to all actions for which you want to add the account wrapper. Note that the original return value is used inside of the new one as a subview:

Rich (BB code):
		// return $this->responseView('XenForo_ViewPublic_Conversation_List', 'conversation_list', $viewParams);

		return $this->_getWrapper(
			'conversations', 'view',
			$this->responseView('XenForo_ViewPublic_Conversation_List', 'conversation_list', $viewParams)
		);

Lastly, you must add this function to the very bottom of the file:

Rich (BB code):
	/**
	 * @return XenForo_Model_Conversation
	 */
	protected function _getConversationModel()
	{
		return $this->getModelFromCache('XenForo_Model_Conversation');
	}

	/**
	 * @return XenForo_Model_Attachment
	 */
	protected function _getAttachmentModel()
	{
		return $this->getModelFromCache('XenForo_Model_Attachment');
	}

	/**
	 * Gets the account pages wrapper.
	 *
	 * @param string $selectedGroup
	 * @param string $selectedLink
	 * @param XenForo_ControllerResponse_View $subView
	 *
	 * @return XenForo_ControllerResponse_View
	 */
	protected function _getWrapper($selectedGroup, $selectedLink, XenForo_ControllerResponse_View $subView)
	{
		return $this->getHelper('Account')->getWrapper($selectedGroup, $selectedLink, $subView);
	}
}

This is the result (after changing the return value on actionIndex()):

Screen shot 2013-03-29 at 12.24.50 PM.webp
 
I did it but there's no change. Here's what my file looks like in library/XenForo/ControllerPublic/Conversation.php

Rich (BB code):
    /**
    * @return XenForo_Model_Attachment
    */
    protected function _getAttachmentModel()
    {
    //    return $this->getModelFromCache('XenForo_Model_Attachment');
            return $this->_getWrapper(
            'conversations', 'view',
            $this->responseView('XenForo_ViewPublic_Conversation_List', 'conversation_list', $viewParams)
        );
    }
    /**
    * Gets the account pages wrapper.
    *
    * @param string $selectedGroup
    * @param string $selectedLink
    * @param XenForo_ControllerResponse_View $subView
    *
    * @return XenForo_ControllerResponse_View
    */
    protected function _getWrapper($selectedGroup, $selectedLink, XenForo_ControllerResponse_View $subView)
    {
        return $this->getHelper('Account')->getWrapper($selectedGroup, $selectedLink, $subView);
    }
}
 
Review my directions again. You did it wrong. You need to modify the return values in the various actions, like actionIndex(). You have modified the _getAttachmentModel() function which is wrong.

This does require that you be able to identify which actions to modify. This can be done more cleanly with an addon.
 
Review my directions again. You did it wrong. You need to modify the return values in the various actions, like actionIndex(). You have modified the _getAttachmentModel() function which is wrong.

This does require that you be able to identify which actions to modify. This can be done more cleanly with an addon.
Thanks Jake, I tried doing it again and made it worse so re-uploaded the original file. Request posted: http://xenforo.com/community/threads/account-settings-sidebar-in-conversations.47483/
 
Back
Top Bottom