[eluser]montanaflynn[/eluser]
Maybe I am missing something but I am having trouble echoing the base_url as defined in the config.php in a view. How would you go about doing this? I have tried adding
Code:
<?php echo $base_url;?>
in the view but it gives an error "Message: Undefined variable: base_url"
Some background info:
This is my first time using a PHP framework and I have decided to convert my static site to Codeignitor. This is what I have done so far:
Filled out the system/config/config.php file & routes.php to make home.php the default controller.
Created a home.php controller with the following:
Code:
<?php
class Home extends Controller {
function index()
{
$data['title'] = "This is the page title";
$data['desc'] = "My site description is complete!";
$this->load->view('homeView', $data);
}
}
?>
Created a homeView.php view with the following (simplyfied):
Code:
<!DOCTYPE html>
<html>
<head>
<title><?php echo $title;?></title>
<meta name="description" content="<?php echo $desc;?>" />
<style src="<?php echo $base_url;?>/css/style.css" type="text/css">
[removed]
</head>
<body>
<h1><?php echo $title;?></h1>
</body>
</html>
Everything works except the base_url, I have a feeling I need to define it in the controller. Any suggestions?