Newbie: Howto Use CSS and Images folder? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Newbie: Howto Use CSS and Images folder? (/showthread.php?tid=6739) |
Newbie: Howto Use CSS and Images folder? - El Forum - 03-10-2008 [eluser]zimco[/eluser] Using CI 1.6.1 I'm not getting how to use a css file and any style related images in an images folder. I put the following lines in the /system/application/config/config.php Code: /* Then created a controller Home like: Code: class Home extends Controller { My /views/layout.php page looks like: Code: <?php echo $header; ?> It is probably a simple concept i am not understanding so could somebody with more CI experience and patience tell me what i am doing wrong? Newbie: Howto Use CSS and Images folder? - El Forum - 03-10-2008 [eluser]Michael Wales[/eluser] You would use them the exact same way as always... assuming your $data['css'] variable is correct, do the following in the view: Code: <link rel="stylesheet" href="<?= $css; ?>" type="text/css" media="screen, projection" charset="utf-8" /> Personally, I make a helper that takes care of it all: Code: <?= css_asset('/assets/css/style.css', 'screen, projection'); ?> Newbie: Howto Use CSS and Images folder? - El Forum - 03-10-2008 [eluser]ontguy[/eluser] I think you may just be missing the folder name: Code: $config['css'] = "/css/default.css"; Newbie: Howto Use CSS and Images folder? - El Forum - 03-10-2008 [eluser]zimco[/eluser] Thanks for the replys to help. However, i seem to have more than that messed-up because in my original header.php file i tried using the variables i set for $css and $base in my header.php file like you suggested: Code: <base href="<?php echo $base; ?>"/> header.php Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> Doing it like $this->css in the header view file does not seem quite right to me, but it works. The $css and $base variable i set in the controller are not available to me in the view but everything else is. It's probably my mis-understanding of how things get passed between controllers and views, but i don't get it? |