Link problem |
[eluser]Gerep[/eluser]
Hi fellas, I'm new here and trying to develop a quotation system but I'm having a little problem. I have the menu with links like: Quote:<ul> If I got it right, the first link will call my user class and execute the index() method. When I click on it for the first time it adds the user to the url like: Quote:http://localhost/quotation/user, when I click the second time, it will be: Quote:http://localhost/quotation/user/userand it makes all my other links wrong, like the Quotation: Quote:http://localhost/quotation/user/user/quotation Am I doing the right thing with links or there is another and better way to deal with them? Thanks in advance
[eluser]spider pig[/eluser]
If I understand what you want to do, you will need to prefix the links with base_url(). This will then insert the correct web address when executed. So the menu would look like this: Code: <ul> To use base_url(), you will need to make sure the URL Helper is loaded in the controller: Code: $this->load->helper('url'); Or, what I do is load it in the config file autoload.php: Code: $autoload['helper'] = array('url');
[eluser]parham90[/eluser]
[quote author="spider pig" date="1280910540"]If I understand what you want to do, you will need to prefix the links with base_url(). This will then insert the correct web address when executed. So the menu would look like this: Code: <ul> To use base_url(), you will need to make sure the URL Helper is loaded in the controller: Code: $this->load->helper('url'); Or, what I do is load it in the config file autoload.php: Code: $autoload['helper'] = array('url'); Or even better, after autoloading (or loading) the url helper, you can put these in your view file, which is, in my opinion, much more readable: Code: <ul> If you have short tags enabled in your CodeIgniter configuration file, you can even make it as short as: Code: <li><?=anchor('user', 'Index')?></li> and so on. For more information about the URL helper and more examples, take a look at the section about the URL helper in the User Guide. HTH! |
Welcome Guest, Not a member yet? Register Sign In |