Welcome Guest, Not a member yet? Register   Sign In
Link problem
#3

[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>
<li><a href="&lt;?= base_url() ?&gt;user">Index</a></li>
<li><a href="&lt;?= base_url() ?&gt;quotation">Quotation</a></li>
</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');
[/quote]

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>
<li>&lt;?php echo anchor('user', 'Index');?&gt;</li>
<li>&lt;?php echo anchor('quotation', 'Quotations');?&gt;</li>
</ul>

If you have short tags enabled in your CodeIgniter configuration file, you can even make it as short as:

Code:
<li>&lt;?=anchor('user', 'Index')?&gt;</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!


Messages In This Thread
Link problem - by El Forum - 08-03-2010, 08:26 PM
Link problem - by El Forum - 08-03-2010, 09:29 PM
Link problem - by El Forum - 08-04-2010, 04:57 AM



Theme © iAndrew 2016 - Forum software by © MyBB