-
-
Save arunoda/ac1706be629328092fab to your computer and use it in GitHub Desktop.
Codeigniter - Creating a custom library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Css { | |
var $files = array(); | |
public function add($file) { | |
$this->files[] = $file; | |
} | |
public function generate() { | |
$cssString = ""; | |
$CI = &get_instance(); | |
$CI->load->helper('html'); | |
foreach($this->files as $file) { | |
$cssString .= link_tag('css/' . $file) . "\n"; | |
} | |
return $cssString; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Hello extends MY_Controller { | |
public function index() { | |
$this->load->library('css'); | |
$this->css->add('main.css'); | |
$this->css->add('print.css'); | |
echo $this->css->generate(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment