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

Add-on Account Settings Sidebar in Conversations

DRE

Well-known member
#1
Our emails have a sidebar, why not conversations? Jake Bunce created the code modification, it just needs an addon cause I don't know how to follow his directions.

http://xenforo.com/community/threads/account-settings-sidebar-in-conversations.47427/#post-509423

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()):

View attachment 43032
*Tries it, fails*

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.