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

Consistency in String Parameters

Discussion in 'XenForo Development Discussions' started by Teapot, Dec 11, 2013.

  1. Teapot

    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($routePathZend_Controller_Request_Http $requestXenForo_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: Dec 12, 2013
  2. Jeremy

    Jeremy XenForo Moderator Staff Member

    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.
     
    xf_phantom and Teapot like this.
  3. Teapot

    Teapot Well-Known Member

    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: Dec 11, 2013

Share This Page