Best way to check a URL and then load the right content? Example inside... |
[eluser]ChrisF79[/eluser]
New to Codeigniter and I'm trying to learn best practices here. Hopefully you guys can give some advice. For my real estate site, I have the URL format: mysite.com/site/property/923749283-123-main-street What I want to do is check the URL and see if there is something behind the /property/ piece. I created the code to do this and it works well. Should I put that in my model? Then, if there is something in the URL to indicate a house, I want to show the page that has the detail for my house. If it is blank, I want to show the standard property search page. So, in my controller, do I run the function to pull the URL and then do an if/then statement to determine which view to load?
[eluser]CroNiX[/eluser]
$this->uri->segment(3) would give you the segment after "property", or FALSE if it doesn't exist. So, in your "property" method you can check for the value of segment 3 and determine what you need to do from there. No need to make your own functions for that. http://ellislab.com/codeigniter/user-gui...s/uri.html
[eluser]ChrisF79[/eluser]
[quote author="CroNiX" date="1338854807"]$this->uri->segment(3) would give you the segment after "property", or FALSE if it doesn't exist. So, in your "property" method you can check for the value of segment 3 and determine what you need to do from there. No need to make your own functions for that.[/quote] I was using that segment to see what was in the URL so that does work nicely. I have to extract the set of numbers before the street address since that is the MLS number used for the database so I figured I'd dump it in a function. Either way though, do I do the if/then in the controller to determine what to load?
|
Welcome Guest, Not a member yet? Register Sign In |