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

Account Settings Sidebar in Conversations?

DRE

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

Our emails have a sidebar, why not conversations?
 

Jake Bunce

XenForo moderator
Staff member
#2
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):

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:

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:

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

DRE

Well-known member
#4
I did it but there's no change. Here's what my file looks like in library/XenForo/ControllerPublic/Conversation.php

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

Jake Bunce

XenForo moderator
Staff member
#5
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.
 

DRE

Well-known member
#6
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/