• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem loading CSS file with relative path

Thanks for the tip @Tominator

I'll try your solution tonight when I get home from the office. Don't worry about your English skills, I'm not a native speaker either, and I didn't have any trouble understanding what you said.

Thanks, I hope this week I will release new version of this parser. I'm going to write documentation right now. I'm so excited!


I'll throw in my solution. I'm using 960 grid system for my project, and need page specific CSS files (admin pages vs external pages, for instance). All of my CSS is stored in a /CSS folder, which I've listed in my .htaccess file. I call three views for each page, header, page-name and footer. I got this from Coder320 here.

function index() {
  $data['title'] = "This is my page title.";
  $data['descr'] = "This is my meta description.";
  $data['css'] = array('/CSS/reset.css', '/CSS/text.css', '/CSS/960.css');
  $this->load->view('header', $data);

<title><?php echo $title;?></title>
<meta name="description" content="<?php echo $descr;?>" />
foreach($css as $file):
  echo '<link rel="stylesheet" type="text/css" media="all" href="'.$file.'" />'."\n";

This renders as:
<title>This is my page title.</title>
<meta name="description" content="This is my meta description." />
<link rel="stylesheet" type="text/css" media="all" href="/CSS/reset.css" />
<link rel="stylesheet" type="text/css" media="all" href="/CSS/text.css" />
<link rel="stylesheet" type="text/css" media="all" href="/CSS/960.css" />

For page specific CSS, I just tack on one more CSS file in the array with those specific updates and it works beautifully.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.