Consistency in String Parameters

Teapot

Well-known member
Quick routing question. I'm trying to make my route's string parameters, which are content tags and therefore are short strings that allow spaces, produce URLs that are more consistent with the string plus integer URLs. Right now, any spaces in tags are escaped as %20, not a dash as usual - so instead of:

/tags/cheese-for-everybody

I'm getting: /tags/cheese%20for%20everybody

Anyone know how to do this in the route controller? Right now it's a very generic one and looks like this:

PHP:
<?php
class Teapot_HashBrown_Route_Tag implements XenForo_Route_Interface
{
    public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
    {
        $action = $router->resolveActionWithStringParam($routePath, $request, 'name');

        return $router->getRouteMatch('Teapot_HashBrown_ControllerPublic_Tag', $action, 'tags');
    }
  
    public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams)
    {
        return XenForo_Link::buildBasicLinkWithStringParam($outputPrefix, $action, $extension, $data, 'name');
    }
}
 
Last edited:
PHP:
XenForo_Link::getTitleForUrl($title, $romanize);

Run it through that and it'll replace invalid characters and replace them so they are consistent with the rest of XenForo.
 
Looks like exactly what I need - although a slightly dumb question now. How do I get the title (the tag name) to plug into that function? Specifically, how do I do it in the match function?

Thanks :)
 
Last edited:
Top Bottom