Trying to create a public route...

Matthew Hawley

Well-known member
I am trying to create a public route.

This is my ControllerPublic/Directory.php code

Code:
<?php

class CF_Directory_ControllerPublic_Directory extends XenForo_ControllerPublic_Abstract
{
    public function actionIndex()
    {
        // send to template for display
        return $this->responseView('CF_Directory_Index', 'cf_directory_index', $viewParams);
}

This is my Route/Prefix/Directory.php code
Code:
<?php

class CF_Directory_Route_Prefix_Index implements Xenforo_Route_Interface
{
   public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
   {
     return $router->getRouteMatch('CF_Directory_ControllerPublic_Directory', $routePath, 'directory');
   }
}

6gub.png


When I go to .com/directory i get

Route directory/ could not be found.

Any suggestions?
 
you named your route file Directory.php, yet your class and route use CF_Directory_Route_Prefix_Index, so either change the class and route to CF_Directory_Route_Prefix_Directory or change the file name to Index.php
 
Class name should correspond to the path of the PHP file relative to the library/ directory (unless using namespaces, when the fully qualified class name should correspond to the path of the PHP file...)

Liam
 
Thanks Bob! I'm getting somewhere. Now I have this error.

Parse error: syntax error, unexpected $end, expecting T_FUNCTION in /home3/xxx/public_html/xxx/library/CF/Directory/ControllerPublic/Directory.php on line 9

Here is the code.

Code:
<?php

class CF_Directory_Route_Prefix_Directory implements Xenforo_Route_Interface

{

   public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)

   {

     return $router->getRouteMatch('CF_Directory_ControllerPublic_Directory', $routePath, 'directory');

   }

}

@Lawrence @Jeremy @Jake Bunce
 
Last edited:
Insistently tagging someone isn't going to get you help faster, it can actually become quite annoying.

Although, you have mismatched braces within your controller. You may want to read and google errors, you'll be surprised what you can learn on the internet. Also, it'd help if you would reference and/or post the files with the actual error in them.
 
Sorry, I didn't receive an alert that I was tagged, odd.

Your top code block in your first post, you are missing the closing } for your actionIndex.
 
Back
Top Bottom