[eluser]Ed Robindon[/eluser]
Hi,
The controller functions are not available to the view. You can, however,
pass the baseurl to the view in an array of data.
Here's a simple test controller:
Code:
<?php
/**
* 9-29-2012
* General testing controller
* test.php in controllers
* Uses the view test_view.php in views
*/
class test extends CI_Controller
{
function __construct()
{
parent::__construct();
}
public function index()
{
//Pass some variables to the view
$data['date'] = date('m/d/Y');
$data['timex'] = date('h:i:s');
//Get the base url for use by the view
$data['baseurl'] = $this->config->item('base_url');
$this->load->view('test_view', $data);
}
}
And the view:
Code:
<!DOCTYPE html>
<html>
<head>
<title>CI Testing View</title>
</head>
<body>
<p>
The current date is <?php echo $date ?>
</p>
<p>
The current time is <?php echo $timex ?>
</p>
<p>
Our base url is <?php echo $baseurl ?>
</p>
<a href="welcome">Home page no baseurl</a> Works without baseurl or htaccess<br/>
<a href="<?php echo $baseurl.'welcome'?>">Home with baseurl</a> Needs an htaccess or index.php added into the url<br/>
<a href="<?php echo $baseurl.'index.php/welcome'?>">Home with baseurl</a> Should work either way
<p>All 3 work wth the htaccess in place</p>
</body>
</html>
Here's my htaccess:
Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Hope this gets you going...
Ed