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

Routing with an ID

Discussion in 'XenForo Development Discussions' started by NixFifty, Aug 22, 2013.

  1. NixFifty

    NixFifty Well-Known 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($routePathZend_Controller_Request_Http $requestXenForo_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.
     
  2. NixFifty

    NixFifty Well-Known Member

    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.
     

Share This Page