Welcome Guest, Not a member yet? Register   Sign In
Problem loading CSS file with relative path
#11

[eluser]mihaibaboi[/eluser]
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.
#12

[eluser]Tominator[/eluser]
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!

Tom.
#13

[eluser]lenwood[/eluser]
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.

Controller:
Code:
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);
  $this->load->view('page-name');
  $this->load->view('footer');

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

This renders as:
Code:
<html>
<head>
<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" />
</head>
<body>

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




Theme © iAndrew 2016 - Forum software by © MyBB