Jump to content

Recommended Posts

You might want to be more specific. Adding a link is as simple as adding the html to your view.

 

This is my header.php file and how i linked it. its not linking to the page:

<div align="center"><a href="<?php  echo('index.php/home') ?>">Home</a>   <a href="<?php anchor('index.php/about') ?>">About</a>   <a href="#">Company</a>   <a href="#">Tutorials</a> </div>

 

pls how do i resolve this? i used two methods there; the echo and anchor but to no avail

 

thanks

<?php echo anchor('target_controller/method', 'anchor text'); ?>

 

So your code:

<div align="center">
<a href="<?php  echo('index.php/home') ?>">Home</a>   
<a href="<?php anchor('index.php/about') ?>">About</a>   
<a href="#">Company</a>   
<a href="#">Tutorials</a> 
</div>

Should look like this:

<div align="center">
<?php echo anchor('home', 'Home'); ?>   
<?php echo anchor('about', 'About'); ?>   
<a href="#">Company</a>   
<a href="#">Tutorials</a> 
</div>

 

 

I left in the html tags for the # links, because CI will parse those as natural links when you use the anchor function.

 

Also, you do not need to indicated 'index.php' as that is already configured in your config/routes.php setup, and links are created by pointing to the controller.

 

<?php echo anchor('target_controller/method', 'anchor text'); ?>

 

So your code:

<div align="center">
<a href="<?php  echo('index.php/home') ?>">Home</a>   
<a href="<?php anchor('index.php/about') ?>">About</a>   
<a href="#">Company</a>   
<a href="#">Tutorials</a> 
</div>

Should look like this:

<div align="center">
<?php echo anchor('home', 'Home'); ?>   
<?php echo anchor('about', 'About'); ?>   
<a href="#">Company</a>   
<a href="#">Tutorials</a> 
</div>

 

 

I left in the html tags for the # links, because CI will parse those as natural links when you use the anchor function.

 

Also, you do not need to indicated 'index.php' as that is already configured in your config/routes.php setup, and links are created by pointing to the controller.

 

 

Thank you very very much Mahngiel. Its been solved. I altered my config file and that caused a major problem even after i have used the format you provided.

On the config file,  $config['base_url'] = 'localhost'; and here i had $config['index_page'] = 'home.php';

but on seeing the error it gave me i knew there was a problem from there so i changed: $config['base_url'] = ''; and $config['index_page'] = 'index.php'; and it did the magic plus the format you showed me.

thanks a zillion dozen times

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.