route

Jake Bunce

Well-known 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...
 
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
 
I am not an addon product. :o

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

A controller for the route path gallery/ was not found.

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.
 
You made the route file, and set it in the admin.php > development > route prefix > (and linked it to your product) ?
 
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
 
Top Bottom