routes question |
[eluser]Emrys[/eluser]
Hey all So I have an interesting question. Well interesting to me anyway . I built my entire site with codeigniter originally. I've now moved to wordpress for the main page, since I don't have enough time to manage the back end, but it's also left me with a bit of a tricky problem as far as the routes go. My main controller used to be (cleverly) called 'main' and I also had a 'gallery' controller. So my url for the gallery used to look something like this : http://main/index.php/gallery/albums Now that main has been removed, I thought I'd cleverly switch my front controller to the gallery. So my base url would be : http://localhost/gallery The problem is, is that now my albums function now lives here : http://localhost/gallery/index.php/gallery/albums Which is not exactly what I want . Does anyone have any ideas on how to do this in a way that actually works? I basically need to make my gallery the front controller without having to rewrite the entire thing. I have this nagging feeling that it should be fairly straightforward but I just can't see it. Thanks in advance Marc
[eluser]Emrys[/eluser]
hmm.. could I phrase this better, or has no-one encountered this before? Thanks Marc
[eluser]Dam1an[/eluser]
I think you're confusing yourself (and definatly confusing me) You talk of main and gallery being controllers and yet in the URL examples, you have index.php after main and gallery respectivly, which would suggest that they're the folder you installed CI in, and in both cases, the controller is gallary (the part after index.php)
[eluser]Emrys[/eluser]
ah..haha... yeah definitely confused. ok here was the original url : http://example.com/index.php/gallery/albums http://example.com/index.php/main/ etc. The second one remains valid though. So now CI is installed to : http://example.com/gallery/ but my primary controller is gallery too, so if I remove the index.php the it would be something like : http://example.com/gallery/gallery/ um, hopefully that's better. Thanks M
[eluser]Dam1an[/eluser]
Ah, that clears things up So all you (should) need is Code: $route['default_controller'] = "gallery";
[eluser]Emrys[/eluser]
ah... that helped clarify things. Thanks I got it working now. Oddly enough I'd actually worked all this out a year ago when I first coded it, it's amazing how things fall away when you don't use them. Thanks again. Marc
[eluser]Emrys[/eluser]
Hey Sorry to resurrect an old problem. But while this solution works it has the potential to get pretty messy. Currently my routes look like this: $route[':num'] = "gallery/index"; $route['search'] = "gallery/search"; $route['albums:any'] = "gallery/albums"; I was wondering if there wouldn't perhaps be a more elegant solution than basically replicating almost every function (ok not every function ) in my routes file? Thanks Marc |
Welcome Guest, Not a member yet? Register Sign In |