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

Admin Route not working

Kirk

Well-known member
#1
So i've created this admin route called Quiz


Route Class Code:
PHP:
<?php
class KAH_Quiz_Route_PrefixAdmin_Quiz implements  XenForo_Route_Interface
{
    public function  match($routePath, Zend_Controller_Request_Http $request, Xenforo_Router $router)
    {
        return $router->getRouteMatch('KAH_Quiz_ControllerAdmin_Quiz', 'Index', 'Quiz', $routePath);
    }
}
The ControllerAdmin
PHP:
<?php
class KAH_Quiz_ControllerAdmin_Quiz extends XenForo_ControllerAdmin_Abstract
{
     public function actionIndex()
     {
         $text = 'This is going to be developed developed soon';

         $viewParams = array(
            'text' => $text
         );
         return $this->responseView('KAH_Quiz_ViewAdmin_Quiz', 'quiz_index', $viewParams);
     }
}
I've created the quiz_index template in the admin templates which has the following
Code:
{$text}
But when i try to go to the Quiz link in the admin panel i get the following error
Route Quiz/ could not be found.
What did I do wrong?
 

Nobita.Kun

Well-known member
#2
PHP:
return $router->getRouteMatch('KAH_Quiz_ControllerAdmin_Quiz', 'Index', 'Quiz', $routePath);
Should be:
PHP:
return $router->getRouteMatch('KAH_Quiz_ControllerAdmin_Quiz', $routePath);
 

Chris D

XenForo developer
Staff member
#7
I have to say, actually, all of that looks mostly correct. @Nobita.Kun's suggestion is right for what you're trying to do in the first instance.

There's no link build function in your code so the setting for "Use class to build link" shouldn't affect anything.

Just spotted it...

upload_2014-7-23_15-54-10.png

It's the good old Xenforo typo. Should be XenForo_Router
 

Kirk

Well-known member
#10
I'm still getting route error

Route Quiz/ could not be found.

:( Why do i have to be a noob when it comes to developing an add-on for XenForo :p
 

Chris D

XenForo developer
Staff member
#11
Well, you're not. This is rather unusual.

It dawned on me about 10 minutes ago that the spelling mistake wouldn't even cause this problem because it's just asserting that the variable should be an object of that class. Presumably as there's no exception being thrown, PHP must not be too fussy about case sensitivity here and it is seeing XenForo_Router and Xenforo_Router as the same thing.

I will try and reproduce the error shortly.
 

Kirk

Well-known member
#12
Well, you're not. This is rather unusual.

It dawned on me about 10 minutes ago that the spelling mistake wouldn't even cause this problem because it's just asserting that the variable should be an object of that class. Presumably as there's no exception being thrown, PHP must not be too fussy about case sensitivity here and it is seeing XenForo_Router and Xenforo_Router as the same thing.

I will try and reproduce the error shortly.
Would you like my code in a zip file?
 

Kirk

Well-known member
#15
Note to myself. next time when i make folders make sure i call them the proper folder names

Route
/PrefixAdmin

Not
Route
/PefixAdmin

Thank you everyone for helping me out with this suppose to be simple problem. I feel so much better asking fellow developers for help :)

You guys rock!
 

Chris D

XenForo developer
Staff member
#17
Yeah I thought so too. Or similar sort of validation via the PHP helper XF has had since 1.3.

I raised a bug report as it seems inconsistent to me.