hi, This is Syed Haroon from Mysore, Karnataka, India.
Assume:
Root Folder Name: ci_test
CSS file name : mystyles.css";
Controller file name: Start.php
view file name: test_view.php
Solution:
Suggestion for WAMP (hope it will be easy to fix the same in xampp):
Save it in root/system/application/css
Create a new CSS directory in application folder (just to Manage files and folder in the correct way)
How to connect back to CSS file?
in system/application/config/config.php
Edit "$config['base_url'] = http://localhost/" to
$config['base_url'] = "http://localhost/ci_test";
Crate a new line
$config['css'] = "system/application/css/mystyles.css";
Create a Controller in "system/application/controllers/start.php" insert the below sample code:
class Start extends Controller {
var $base;
var $css;
function Start(){
parent::Controller();
$this->base = $this->config->item('base_url');
$this->css = $this->config->item('css');
}
function hello(){
$data['css'] = $this->css;
$data['base'] = $this->base;
$data['mytitle'] = 'Welcome to this site';
$data['mytext'] = "Hello, now this is how CSS work!";
$this->load->view('test_view', $data);
}
}
Crate a view file in "system/application/views/test_view.php" insert the below sample code:
<html>
<head>
<title>Web test Site</title>
<base href= <?php echo "$base"; ?> >
<link rel="stylesheet" type="text/css" href="<?php echo "$base/$css";?>">
</head>
<body>
<h1><?php echo $mytitle; ?> </h1>
<p class='test'> <?php echo $mytext; ?> </p>
</body>
</html>
now enter this in ur address bar of the browser "http://localhost/ci_test/index.php/start/hello/"