Load different data depending on URL? |
[eluser]invision[/eluser]
Hi, I have a URL: http://www.site.com/index.php/scotland/glasgow/hotels/ I want to do different things depending on what part of the URL the user is visiting. E.g. if they're on /index.php/scotland/ it'd show different data than when on the full URL above. How do I achieve this with CodeIgniter? On a previous thread, I got as far as the following...but it didn't work I tried to take in the three different parts of the URLs as parameters ($param_1 etc...) Controller: Code: function index($param_1 = FALSE, $param_2 = FALSE, $param_3 = FALSE) { - - For reference my Model is: Code: <?php I would massively appreciate any guidance with this. Many thanks.
[eluser]WanWizard[/eluser]
Use a different way of processing the parameters: Code: if ( $param_1 === FALSE )
[eluser]invision[/eluser]
Aaaaaaah, now that sounds sensible I'll give it a try and report back post haste.
[eluser]invision[/eluser]
I've given this a shot, but it displays 'country' no matter what part of the URL I'm at I just need to show Country data if the URL is at: http://localhost/ae/index.php/gbr/ City data if the URL is at: http://localhost/ae/index.php/gbr/glasgow/ Category data if the URL is at: http://localhost/ae/index.php/gbr/glasgow/hotels/ Thanks again for any advice.
[eluser]invision[/eluser]
My Controller code: Code: <?php
[eluser]WanWizard[/eluser]
Ok, then I misunderstood the question. But indeed, if you leave out the 'limited' parts like in your last post, it should work the way you want.
[eluser]invision[/eluser]
Thanks for the reply. It still doesn't seem to work when I use the code in my last post. It still displays 'Country' even when I'm down at the 'City' or 'Category' part of the site. Is there a better way of doing this that you know of? Really appreciate the help.
[eluser]techgnome[/eluser]
Reverse the check... check for the third parameter FIRST... if it exists, display the info. If it doesn't, then check the second... if it exists, display the info... if it doesn't then check the first... and so on. -tg
[eluser]invision[/eluser]
Thanks for the reply TG. Can you explain what you mean using my code from post #4. I've tried reversing it at my end, but it's not quite working. Thanks again
[eluser]techgnome[/eluser]
See if this works: Code: <?php -tg |
Welcome Guest, Not a member yet? Register Sign In |