• 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

Gossamer

Active member
#1
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.


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($routePath, Zend_Controller_Request_Http $request, XenForo_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:


Any ideas what I'm doing wrong?
 

Liam W

Well-known member
#3
What is the exact location of the controller file?

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

Liam
 

Gossamer

Active member
#4
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