As designed 1.2 setIndexRoute bug

tenants

Well-known member
There seems to be a bug with setIndexRoute that affects how template links appear

If I set the index route for my home page as:

XenForo_Link::setIndexRoute('xz-articles');

The home page gets set correctly (so I can navigate to example.com), but when clicking the link from the nav, I'm redirected to the example.com/xz-articles

However, If I set the route using

XenForo_Link::setIndexRoute('xz-articles/');

Then both the nav link and navgating to the site direct me to example.com (as expected)


However, if the route prefix has an action, then the reverse is true

XenForo_Link::setIndexRoute('xz-articles/category-list'); Works
XenForo_Link::setIndexRoute('xz-articles/category-list/'); Doesn't work

my work around for now is to use:

Code:
        switch ($options->xzSetHomePage)
        {    
            case 'article_list':
                XenForo_Link::setIndexRoute('xz-articles/');
            break;
            case 'category_list':
                XenForo_Link::setIndexRoute('xz-articles/category-list');
            break;
            case 'editors_picks':
                XenForo_Link::setIndexRoute('xz-articles/editors-picks');
            break;                                
            default:
            break;
        }

But you can see that this is a bit strange
 
Last edited:

Mike

XenForo developer
Staff member
The match is an exact match for a URL, so there's nothing that looks particularly unexpected to me there. Your category-list and editors-picks appear to be actions and thus don't have a trailing slash -- you'll see this all over XF as a standard approach (trailing slash only on the prefix and to identify content).

Depending on the route setup, prefix/x/ and prefix/x can mean different things (try it with a forum with a URL portion). As such, I'm not sure if we can just wholesale ignore a trailing slash. I'll have to think about this a bit.
 

tenants

Well-known member
prefix/x/ and prefix/x can mean different things
That's true, hmmm

If it is a bug, it's a low priority/severity, the work around above works fine

I just didn't want to start doing things a certain way, only to find it's fixed later

If you are saying this is intending behaviour, not fixing this (and future not fixing) is preferable than fixing it at a later date so that the indexRoute only works with/without the trailing slash (breaking the above work around.. which is not really a work around)
 

Mike

XenForo developer
Staff member
Yeah, thinking about it more, because of the potential ambiguity, anything that we do to manipulate trailing slashes could introduce issues.

So as designed then. :)
 
Top