Aby Sebastian Aby Sebastian - 6 months ago 14
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
base_url()
,
site_url()
and
current_url()
but this error displays:


You don't have permission to access
/Buildon/User/views/contact.php
on this server.

Answer

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.

Incorrect

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