CodeIgniter Forums
Trouble With Routes - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Trouble With Routes (/showthread.php?tid=12961)



Trouble With Routes - El Forum - 11-05-2008

[eluser]Bl4cKWid0w[/eluser]
I am trying to make a clan ladder site. I want the url to be like the following example:
mysite.com/ladders/xbox-360/halo-3/team-slayer

I have the ladders controller. The second uri segment would be the "console" function and the the third segment would be the game function. The fourth segment would be the ladder function.

These are my routes:
Code:
$route['ladders/:any'] = "ladders/console";
$route['ladders/console/:any'] = "ladders/console/gameview";
$route['ladders/console/gameview/:any'] = "ladders/console/gameview/ladderview";

The index function lists all the consoles that the site supports.

The console function lists all the games under the console that the user previously selected at the index page.

The game function lists all the ladders under the game that the user previously selected at the console page.

The ladder function lists all the clans under the ladder that the user previously selected at the game page.

The index function works fine as does the console function, but when I click on a game link, nothing happens even when the url is ladders/xbox-360/halo-3/team-slayer


Trouble With Routes - El Forum - 11-05-2008

[eluser]narkaT[/eluser]
how about:
Code:
$route['ladders(:any)'] = "ladders/display$1";

and
Code:
class Ladders {
    //...

    function display($console = null, $game = null, $team = null) {

        switch(null) {
            case !empty($console):
                //console overview
                break;
            case !empty($console) && !empty($game):
                //game overview
                break;
            case !empty($console) && !empty($game) && !empty($team):
                //team stats
                break;
            default:
                //general overview
                break;
        }

    }
}

just an idea Wink


Trouble With Routes - El Forum - 11-06-2008

[eluser]Bl4cKWid0w[/eluser]
Will that be usable with the pretty urls?


Trouble With Routes - El Forum - 11-07-2008

[eluser]Aken[/eluser]
Reverse the order your rules are in. The most specific ones should go first, and the most generic ones last.


Trouble With Routes - El Forum - 11-07-2008

[eluser]narkaT[/eluser]
[quote author="Bl4cKWid0w" date="1226040572"]Will that be usable with the pretty urls?[/quote]

that's what it is meant for Wink