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

route

Discussion in 'XenForo Development Discussions' started by Jake Bunce, Sep 17, 2011.

  1. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    How I do define the URL route for my addon? I am creating a skeleton right now and this one piece has escaped me...
     
  2. Floris

    Floris Guest

    under your library/Jake/Route/Route.php
    have something like this:

    Code:
    <?php
    
    /**
     * meow
     **/
    
    // Jake == dir Jake/ Route == dir Route and Route at the end is Route.php
    class Jake_Route_Route implements XenForo_Route_Interface
    {
    	public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
    	{
    		// route for /jake/
    		return $router->getRouteMatch('Jake_ControllerPublic_Jake', 'index', 'jake', $routePath);
    	} // public
    } // class
    # EOF
    
    and in the admin > dev > route prefix, add the class name Jake_Route_Route to route class, and set prefix to jake

    the custom page is like library/Jake/ControllerPublic_Jake/Jake.php

    Code:
    <?php
    
    class XenFans_ExtraPage_ControllerPublic_About extends XenForo_ControllerPublic_Abstract
    {
    	public function actionIndex()
    	{
    		return $this->responseView('Jake_ViewPublic_Jake', 'jake_template_content', $viewParams);
    	} // public
    } // class
    #EOF
    
    and eh .. i hope that's about it. lol
     
    Dan and Jake Bunce like this.
  3. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    I am not an addon product. :eek:

    I got all that setup but the URL doesn't work. I get:

    When I export my product the XML file has no route prefix:

    Code:
      <route_prefixes/>
    
    I can't find where to define that when creating an addon.
     
  4. Floris

    Floris Guest

    You made the route file, and set it in the admin.php > development > route prefix > (and linked it to your product) ?
     
    Jake Bunce likes this.
  5. Onimua

    Onimua Well-Known Member

    You created the files and defined the route in the ACP?
     

    Attached Files:

    Jake Bunce likes this.
  6. Floris

    Floris Guest

    in his screenshot

    Route prefix: jake (reflects .com/xenforo/jake/ so to speak)
    the class input field is how you call the class in the .php file

    class dir_dir_dir_file (minus the .php)

    library/JakesAddons/Gallery/Route/Gallery.php

    class JakesAddons_Gallery_Route_Gallery { .. }

    responseView has index, gallery, $whatever
     
    Jake Bunce likes this.
  7. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Ugh. Yeah I just saw that:

    Screen shot 2011-09-16 at 6.45.06 PM.png

    I am blind.
     
  8. Floris

    Floris Guest

    Hope that solves it.
     

Share This Page