Reputation: 55
I can't figure out how to do the url links.
Basically I have my navigation bar, and I don't know which CodeIgniter URL code to use and how to implement it.
Is what I'm doing here right?:
<?php $this->load->helper('url'); ?>
<li><a href=" <?php echo site_url("views/about.html"); ?>">About Us</a></li>
I tried to do an anchor like this, but when I load the page it just turns up blank:
<?php echo anchor('views/about.html', 'About Us', title='About Us'); ?>
What am I doing wrong?
Upvotes: 1
Views: 5273
Reputation: 28763
You have to try like this
<a href=" <?php echo site_url()."views/about.html"; ?>">About Us</a>
or you can give like
<a href=" <?php echo site_url(views/about); ?>">About Us</a>
and in the "about" function you put
$this->load->view('about');
but i think the firstone will works for you fine.
Upvotes: 0
Reputation: 12197
There are two ways to make links:
CodeIgniter helper style:
<?php echo anchor('about', 'About us', 'title="About us link"'); ?>
More common HTML with URL echo:
<a href="<?php echo site_url('about');?>" title="About us link">About us</a>
Both will output:
<a href="http://your_url/about" title="About us link">About us</a>
Though if I understand what you are trying to achieve, your mistake is elsewhere.
views
part, as your URL should point to the controller, not a view. The only case is if you have a controller named views
. .html
in URL's by default. It does if you've set them up in your config
file in $config['url_suffix'] = '';
, which is null by default.See if you've made any of these mistakes.
Upvotes: 1
Reputation: 582
That is another way on how you do the URL if you are using the URL helper in CI. You should try this, make the base_url()
as the value for href
. Try this,
<a href="<?php echo base_url()?>/views/aboutus.html">About Us</a>
Upvotes: 1