site_url adding form vars |
[eluser]Monarobase[/eluser]
Hello, I've noticed that codeigniter automaticaly adds any vars contained in the uri that are not specified For example if I have Code: function pagetypeone($var1='', $var2='', $var3='') {} And in my view template called inside this function I have Code: <?=site_url(pageclass/pagetypeone)?> Code: http://mydomain.ext/pageclass/pagetypeone/var1/var2/var3 My problem is that I want to create a link to http://mydomain.ext/pageclass/pagetypeone and not to http://mydomain.ext/pageclass/pagetypeon.../var2/var3 I guess that if I don't want to use the anchor function I need to do something like this : Code: print(base_url()."/pageclass/pagetypeone"); Is there a better way to do this ?
[eluser]danmontgomery[/eluser]
Any reason you're passing pageclass/pagetypeone as constants? Code: <?=site_url('pageclass/pagetypeone')?> works fine for me Quote:http://localhost/ci/pageclass/pagetypeone/
[eluser]mattpointblank[/eluser]
Maybe declare the function like Code: function pagetypeone($var1=NULL, $var2=NULL, $var3=NULL) {}
[eluser]Monarobase[/eluser]
Sorry I didn't explain the problem very well URL I want to have in my link : Code: http://localhost/ci/pageclass/pagetypeone Page I want the link to be shown in : Code: http://localhost/ci/pageclass/pagetypeone/var1/var2/var3 When I use : Code: <?=site_url('pageclass/pagetypeone')?> Code: http://localhost/ci/pageclass/pagetypeone/var1/var2/var3 Code: http://localhost/ci/pageclass/pagetypeone --- To make things a bit easier to understand here is a situation that would need this Code: http://localhost/ci/shop/items/shoes/desc So I would have a class called shop that contains a function called items : Code: function items($search = '', $order= 'asc') {} Now when a user has searched for shoes and the list comes up I want to be able to go back to the full list (by removing /shoes/desc from the uri). But for some reason : Code: <?=site_url('shop/items')?> Code: http://localhost/ci/shop/items/shoes/desc Code: http://localhost/ci/shop/items I don't know if this is any clearer but the URL helper seems to add any non specified variables to the uri that are already passed onto the function from the inital URL.
[eluser]danmontgomery[/eluser]
The site_url function returns only: - The parameter passed in the function call - $config['base_url'] - $config['index_page'] - $config['url_suffix'] Three of those four things are defined in ./application/config/config.php, the third is what you pass as an argument... So, if site_url() is appending anything extra to that, it's something that you've either defined in config.php or are passing as a parameter, or a customization to that function that you've made.
[eluser]Monarobase[/eluser]
Thankyou that's what I expected it to do. I haven't changed anything like this however I will go through my code again to make double sure that there isn't a mistake anywhere ... |
Welcome Guest, Not a member yet? Register Sign In |