Routing with an ID

Naz

XenForo developer
Staff member
Okay so, I have mod. Currently it displays rows in the table it queries in a list. Each row has an ID and if I click a list item, I want it to pass the ID of that item to the URL and open up the data related to that row in the DB.

Right now, I can't get it to pass to the URL. Can someone offer any pointers?

This is the /Route/PrefixAdmin/Conversation.php file:

PHP:
<?php
class ReadConversations_Route_PrefixAdmin_Conversations implements XenForo_Route_Interface
{
    public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
    {
        $action = $router->resolveActionWithIntegerParam($routePath, $request, 'conversation_id');
        return $router->getRouteMatch('ReadConversations_ControllerAdmin_Read', $action, 'users');
    }
    public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams)
    {
        return XenForo_Link::buildBasicLinkWithIntegerParam($outputPrefix, $action, $extension, $data, 'conversation_id');
    }
}

And here's the ControllerAdmin/Read.php file:

PHP:
<?php

class ReadConversations_ControllerAdmin_Read extends XenForo_ControllerAdmin_Abstract
{

    protected function _preDispatch($action)
    {
        $this->assertAdminPermission("readConversations");
    }

    public function actionIndex()
    {
        return $this->responseView('XenForo_ViewAdmin', 'conversations');
    }

    public function actionLatest()
    {
        $convModel = $this->_conversationsModel();

        $viewParams = array(
            'conversations' => $convModel->getLatestConversations()
            );

        return $this->responseView('XenForo_ViewAdmin', 'conversations_latest', $viewParams);
    }

    public function actionRead()
    {
        $conversationID = $this->_input->filterSingle('conversation_id', XenForo_Input::UINT);

        $conversation = $this->_conversationsModel()->getConversationById($conversationID);

        $viewParams = array(
            'conversation' => $conversation
            );
        return $this->responseView('XenForo_ViewAdmin', 'conversations_read', $viewParams);
    }

    protected function _conversationsModel()
    {
        return $this->getModelFromCache("ReadConversations_Model_Conversations");
    }
}

Any pointers would be superb. Thanks.
 
Perhaps I'm not clear enough on what I wanted.

In the ACP, when listing all users (user_list), if you click a user, you're taken to their page based on what ID was passed through the URL. I'm trying to achieve similar results. Any help would be superb.
 
Top Bottom