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

Admin Route not working

Discussion in 'XenForo Development Discussions' started by Kirk, Jul 23, 2014.

  1. Kirk

    Kirk Well-Known Member

    So i've created this admin route called Quiz
    [​IMG]

    Route Class Code:
    PHP:
    <?php
    class KAH_Quiz_Route_PrefixAdmin_Quiz implements  XenForo_Route_Interface
    {
        public function  
    match($routePathZend_Controller_Request_Http $requestXenforo_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
    What did I do wrong?
     
  2. Nobita.Kun

    Nobita.Kun Well-Known Member

    PHP:
    return $router->getRouteMatch('KAH_Quiz_ControllerAdmin_Quiz''Index''Quiz'$routePath);
    Should be:
    PHP:
    return $router->getRouteMatch('KAH_Quiz_ControllerAdmin_Quiz'$routePath);
     
  3. Kirk

    Kirk Well-Known Member

    I changed that but i still get
    Route Quiz/ could not be found.
     
  4. Nobita.Kun

    Nobita.Kun Well-Known Member

    In ACP link should be: admin.php?quiz/ have you try it?
     
  5. Kirk

    Kirk Well-Known Member

    i have tried that and i still get the same error.
     
  6. Daniel Hood

    Daniel Hood Well-Known Member

    "only when data is provided", try switching that to always and see what happens.
     
  7. Chris D

    Chris D XenForo Developer Staff Member

    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
     
    toodlez, Daniel Hood and Nobita.Kun like this.
  8. Daniel Hood

    Daniel Hood Well-Known Member

    ahh that pesky lowercase f.
     
    Chris D likes this.
  9. Nobita.Kun

    Nobita.Kun Well-Known Member

    oh my god!
     
  10. Kirk

    Kirk Well-Known Member

    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
     
  11. Chris D

    Chris D XenForo Developer Staff Member

    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.
     
  12. Kirk

    Kirk Well-Known Member

    Would you like my code in a zip file?
     
  13. Chris D

    Chris D XenForo Developer Staff Member

    Yeah can do. Would be easier to test that way.
     
  14. Kirk

    Kirk Well-Known Member

    Sent you a message @Chris D with my code attached to it.
     
    Last edited: Jul 23, 2014
  15. Kirk

    Kirk Well-Known Member

    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!
     
  16. Dan

    Dan Well-Known Member

  17. Chris D

    Chris D XenForo Developer Staff Member

    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.
     
    Kirk likes this.

Share This Page