Aby Sebastian Aby Sebastian - 1 year ago 49
PHP Question

How can we link view to view without the help of controller

I am new to CodeIgniter, and I don't know whether this is possible or not. How can I link view to view without the help of controller just like PHP.

{ <a href=''>contact.php</a> }

I tried
but this error displays:

You don't have permission to access
on this server.

Answer Source

When your using codeIgniter site url or base url etc. You should send them to the controller.

CodeIgniter Doc's http://www.codeigniter.com/docs

URI Routing: http://www.codeigniter.com/user_guide/general/routing.html

URL Helper: http://www.codeigniter.com/user_guide/helpers/url_helper.html

Lets say

<a href="<?php echo base_url('contact_us');?>">Contact Us</a>

The contact_us in the base_url would be controller name.

Or Example

<a href="<?php echo base_url('controller_name');?>">Example</a>
<a href="<?php echo base_url('controller_name/function');?>">Example</a>

If you try to send the link to view file will not work.


<a href="<?php echo base_url('application/views/example.php');?>">Example</a>