Part of the EllisLab Network
   
 
Recommended way to use stylesheet file?
Posted: 27 January 2007 01:46 PM   [ Ignore ]  
Summer Student
Total Posts:  28
Joined  01-24-2007

Hello,

Found a hoster that allows URL rewriting grin Next step, using a CSS file.

With CI living under /igniter (/public_html/igniter when connecting through FTP), I tried the following things to use a stylesheet, but they don’t work, ie. the CSS file seems to be ignored:

- uploaded style.css in ./views, and used this in view file:
<meta http-equiv=“content-type” content=“text/html; charset=iso-8859-1”>
<link href=“style.css” type=“text/css”>

- created /public_html/igniter/css/, uploaded style.css there, and used this:
<meta http-equiv=“content-type” content=“text/html; charset=iso-8859-1”>
<link href=”/public_html/igniter/css/style.css” type=“text/css”/>

- did this:
<link type=“text/css” href=”<?php base_url(); ?>/css/style.css” />
but I get this:
  Fatal error: Call to undefined function: base_url() in /public_html/igniter/system/application/views/mainview.php on line 9

Is it because of the URL rewriting in .htaccess? What do you recommend to use CSS in CI?

Thank you.

PS : And if you know why I get “” as the very first characters when the page is displayed, I’m interested.

Profile
 
 
Posted: 27 January 2007 01:52 PM   [ Ignore ]   [ # 1 ]  
Summer Student
Avatar
Total Posts:  15
Joined  01-27-2007

Hi Fred,

Did you load the URL helper? base_url() function is in the Url Helper and must either be explicitly loaded or you need tyo autoload it in your config/autoload.php file.

Hope it helps.

 Signature 

My geeky fetishes @ http://stii.za.net

Profile
 
 
Posted: 27 January 2007 02:30 PM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  28
Joined  01-24-2007
Stii - 27 January 2007 01:52 PM

Did you load the URL helper? base_url() function is in the Url Helper and must either be explicitly loaded or you need tyo autoload it in your config/autoload.php file.

Thanks. No, I thought it was part of CI, so didn’t use it. I’ll check how to add it to the site.

Anyway, more reading of the archives revealed that it was indeed due to .htaccess. To tell Apache not to mess with the URL when it contains a reference to CSS, use this cond:

RewriteEngine on
RewriteRule
^$ index.php [L]

RewriteCond
$1 !^(index\.php|images|css)
RewriteRule ^(.*)$ index.php/$1 [L]

I’m still getting “<html>” when Igniter renders the view, though, although the view file doesn’t contain those funny characters. Could this be due to charsets?

<html>

<
head>
    <!--
meta http-equiv="content-type" content="text/html; charset=utf-8"-->
    <
meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
    <
link rel="stylesheet" type="text/css" href="/igniter/css/style.css" />
    <
title><?php echo $title; ?></title>
</
head>

<
body>

Thank you.

Profile
 
 
Posted: 27 January 2007 02:36 PM   [ Ignore ]   [ # 3 ]  
Summer Student
Total Posts:  28
Joined  01-24-2007

Solved: UltraEdit seems to be set to save files in UTF-8, although I thought it was the usual 8859.

And URL helper works by just adding the following to the controller before loading the view:

$this->load->helper('url');

Thanks.

Profile
 
 
Posted: 27 January 2007 02:52 PM   [ Ignore ]   [ # 4 ]  
Summer Student
Avatar
Total Posts:  15
Joined  01-27-2007

No Probs!

 Signature 

My geeky fetishes @ http://stii.za.net

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 719, on June 06, 2008 10:16 AM
Total Registered Members: 64458 Total Logged-in Users: 16
Total Topics: 80971 Total Anonymous Users: 1
Total Replies: 435716 Total Guests: 177
Total Posts: 516687    
Members ( View Memberlist )