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

Controller for route could not be found

Discussion in 'XenForo Development Discussions' started by Gossamer, May 15, 2016.

  1. Gossamer

    Gossamer Active Member

    I'm trying to setup an admin route, but I keep getting an error that it can't find the controller for my route. Here is what I have so far:

    I've created the route prefix.
    [​IMG]

    Created code for the route prefix:
    PHP:
     class Goss_RPGSkillSystem_Route_PrefixAdmin_SkillCategory implements XenForo_Route_Interface
    {
        
    /**
        * Match a specific route for an already matched prefix.
        *
        * @see XenForo_Route_Interface::match()
        */
        
    public function match($routePathZend_Controller_Request_Http $requestXenForo_Router $router)
        {

            return 
    $router->getRouteMatch('Goss_RPGSkillSystem_ControllerAdmin_Category'$routePath'skill-categories');
        }
        
    /**
        * Method to build a link to the specified page/action with the provided
        * data and params.
        *
        * @see XenForo_Route_BuilderInterface
        */
        
    public function buildLink($originalPrefix$outputPrefix$action$extension$data, array &$extraParams)
        {
            return 
    XenForo_Link::buildBasicLinkWithIntegerParam($outputPrefix$action$extension$data);
        }
    }
    Created a ControllerAdmin file:
    PHP:
    class Goss_RPGSkillSystem_ControllerAdmin_Category extends XenForo_ControllerAdmin_Abstract
    {
        public function 
    actionIndex()
        {
            
    $viewParmas = array();

            return 
    $this->responseView('Goss_RPGSkillSystem_ViewAdmin_Index''goss_skillsystem_category_list'$viewParams);
        }
       
    }
    And lastly I created a template titled goss_skillsystem_category_list with some placeholder text in it.

    However, when I try to go to admin.php?skill-categories, I get this error:
    [​IMG]

    Any ideas what I'm doing wrong?
     
  2. katsulynx

    katsulynx Well-Known Member

    Did you miss the opening "<?php" on your Controller File?
     
    Gossamer likes this.
  3. Liam W

    Liam W Well-Known Member

    What is the exact location of the controller file?

    It should be library/Goss/RPGSkillSystem/ControllerAdmin/Category.php, case sensitive.

    Liam
     
    Gossamer likes this.
  4. Gossamer

    Gossamer Active Member

    Thanks! Turned out I was missing the <?php. Or rather, I had <? php and that space broke it.

    My link is loading now. However, the template isn't rendering on that page. Here is the code for my controller:

    PHP:
    <?php
    class Goss_RPGSkillSystem_ControllerAdmin_Category extends XenForo_ControllerAdmin_Abstract
    {
        public function 
    actionIndex()
        {
            
    $viewParams = array();

            return 
    $this->responseView('XenForo_ViewAdmin_Base''goss_skillsystem_category_list'$viewParams);
        }
       
        
    /** 
        * Get the category model.
        *
        * @return Goss_RPGSkillSystem_Model_Category
        */
        
    protected function _getCategoryModel()
        {
            return 
    $this->getModelFromCache 'Goss_RPGSkillSystem_Model_Category' );
        }
       
    }
    ?>
    I double checked that the template title matched too. goss_skillsystem_category_list
     
  5. Gossamer

    Gossamer Active Member

    Nevermind! Realized I had created my template in the regular section instead of with the admin templates.
     

Share This Page