This is Syed Haroon from Mysore, Karnataka, India.
Suppose: Root folder name: ci_test CSS file name: mystyles.css "; Controller file name: Start.php view file name: test_view.php
Decision:
Suggestion for WAMP (hope this will be easy to fix in xampp):
Save it in root / system / application / css file
Create a new CSS directory in the application folder (only for proper file and folder management)
How to connect to CSS file?
in system / application / config / config.php Change "$ config ['base_url'] = http: // localhost / " to
$config['base_url'] = "http://localhost/ci_test";
Enter a new line
$config['css'] = "system/application/css/mystyles.css";
Create a controller in "system / application / controller / start.php", insert the following code example:
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); } }
Contain the view file in "system / application / views / test_view.php" insert the following code sample:
<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 the address bar of your browser " http: //localhost/ci_test/index.php/start/hello/ "
Syed haroon
source share