Welcome Guest, Not a member yet? Register   Sign In
The style sheet for a view page can't be separated in an Includes folder?
#31

[eluser]alvaroeesti[/eluser]


well, it does load the html file as long as you place the extension there, I know that about how to load it from the controller.

what baffles me is why such a simple thing as just importing a style sheet from the head of the header file is just not working. i have tried all the paths possible. the only thing that works is when the css code is in the header page itself, in full, but I dont want that.

like I said, I would not even need to use url helpers of base url functions to import a style sheet, it should grab it relative to the referencing, calling page


#32

[eluser]CroNiX[/eluser]
It does make things a lot easier if you use a virtual server in apache for each project instead of just having subdirectories. Then everything is truly in "root" as DOCUMENT_ROOT will be pointing to its own dir and will match your live production server.

What happens if you use
Code:
@import url('/CI/css/style.css');</style>

It looks like with your setup your root dir is actually "/CI". The DOCUMENT_ROOT is probably htdocs, unless you've created a virtual server.
#33

[eluser]sith4life[/eluser]
if you have fixed the issue with base_url() and the page renders without errors (minus the lack of styles) view source and post what the link shows exactly from the source as the browser shows it. there may be some malformed url or something.
#34

[eluser]TWP Marketing[/eluser]
[quote author="alvaroeesti" date="1343162249"]

..., it should grab it relative to the referencing, calling page

[/quote]

Yes, but note what CroNix said earlier about protected directories:

Quote:CroNix: "You can’t directly access anything in the /system or /application folder via the URL. They are protected. So putting your css file in the views dir won’t be directly accessible from the URL, which means you can’t use them for assets."
#35

[eluser]alvaroeesti[/eluser]


the page always renders, except the style.css

the structure of my installation is

C:\xampp\htdocs\CI\application\views\header.html

and the URL from the browser

http://localhost/CI/index.php/welcome/index/

and the config
$config['base_url'] = 'http://localhost/CI/';
#36

[eluser]sith4life[/eluser]
[quote author="alvaroeesti" date="1343162974"]

the page always renders, except the style.css

the structure of my installation is

C:\xampp\htdocs\CI\application\views\header.html

and the URL from the browser

http://localhost/CI/index.php/welcome/index/

and the config
$config['base_url'] = 'http://localhost/CI/';[/quote]

ok let me be more specific, load the page http://localhost/CI/ in your browswer, then right-click -> view source. copy/paste the displayed page into a post so I (and other posters) can see how the browser is interpreting the stylesheet URL and I guess all the other information. as the browser sees it. reason being is that CSS is a client-side language so it has to be "handed to the client correctly" and the seeing how the browser sees it will help in diagnosing your issue.
Smile
#37

[eluser]alvaroeesti[/eluser]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

&lt;html&gt;

&lt;head profile="http://gmpg.org/xfn/11"&gt;
&lt;title&gt;&lt;div>

<h4>A PHP Error was encountered</h4>

<p>Severity: Notice</p>
<p>Message: Undefined variable: page_title</p>
<p>Filename: views/header.php</p>
<p>Line Number: 6</p>

</div>&lt;/title&gt;
&lt;link rel="shortcut icon" href="image/favicon.ico" /&gt;

&lt;style type='text/css' media='all'&gt;@import url('CI/css/style.css');&lt;/style&gt;
&lt;link rel='stylesheet' type='text/css' media='all' href=CI/css/style.css' /&gt;
&lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt;
&lt;meta http-equiv="content-language" content="en-gb" /&gt;
&lt;meta http-equiv="imagetoolbar" content="false" /&gt;
&lt;meta name="author" content="Christopher Robinson" /&gt;
&lt;meta name="copyright" content="Copyright © Christopher Robinson 2005 - 2007" /&gt;
&lt;meta name="description" content="" /&gt;
&lt;meta name="keywords" content="" /&gt;
&lt;meta name="last-modified" content="Sat, 01 Jan 2007 00:00:00 GMT" /&gt;
&lt;meta name="mssmarttagspreventparsing" content="true" /&gt;
&lt;meta name="robots" content="index, follow, noarchive" /&gt;
&lt;meta name="revisit-after" content="7 days" /&gt;
&lt;/head&gt;

&lt;body&gt;
<div id="header">
<h1>Your Website</h1>
<h2>catchy slogan..</h2>
</div>
<div id="navigation">
<ul>
<li><a href="#">link one</a></li>
<li><a href="#" class="active">active link</a></li>
<li><a href="#">link three</a></li>
<li><a href="#">link four</a></li>
<li><a href="#">link five</a></li>
<li><a href="#">link six</a></li>
</ul>
</div>

<div id="content"> &lt;!-- this div will close at the start of the footer --&gt;



<h1>Content Header</h1>


<div id="login_form">

&lt;form name="login_form" action ="process_login.php" method="POST"&gt;Email: <br>&lt;input type = "field" name ="email"&gt; <br>Password: <br>&lt;input type = "password" name ="password"&gt;&lt;p>&lt;input type ="submit"&gt;&lt;/ form>



</div>



<div id="footer">
<p>Copyright &copy; <a href="#">Plain and Simple</a> 2007 | Designed by <a href="http://www.edg3.co.uk/">edg3.co.uk</a> | Sponsored by <a href="http://www.opendesigns.org/">Open Designs</a> | Valid <a href="http://jigsaw.w3.org/css-validator/">CSS</a> &amp; <a href="http://validator.w3.org/">XHTML</a></p>
</div>
&lt;/body&gt;

&lt;/html&gt;
#38

[eluser]Aken[/eluser]
So much discussion for such a simple problem... http://ellislab.com/forums/viewthread/214739/

1) You have an error notice for a missing $page_title variable. You should fix it or remove it, as unnecessary stuff in the header can affect output.

2) Don't use @import AND &lt;link&gt; for the same file, it's redundant and pointless. Use &lt;link&gt;.

3) The problem is you are still generating relative links (note there is no beginning / on the CSS URL). The web root for your localhost server is http://localhost/. You need to either use absolute URLs (ones that begin with a slash) and take your CI subdirectory into account, or use the base_url() helper.

/css/style.css = NO. This will look for http://localhost/css/style.css, which does not exist.
CI/css/style.css = NO. This will ADD this URL onto whatever URL is currently viewed. Given your example URL, it will effectively be looking for http://localhost/CI/index.php/welcome/in.../style.css.

Correct options:

Code:
&lt;link href="/CI/css/style.css" rel="stylesheet" type="text/css" /&gt;

&lt;link href="&lt;?php echo base_url('css/style.css'); ?&gt;" rel="stylesheet" type="text/css" /&gt;
#39

[eluser]alvaroeesti[/eluser]


Got it:

What I did, is get the relative paths the proper way. I wrote this and it fetched it

Code:
&lt;style type='text/css' media='all'&gt;@import url('./css/style.css');&lt;/style&gt;
&lt;link rel='stylesheet' type='text/css' media='all' href=./css/style.css /&gt;

Note the 'dot' which is just climbing one directory above, that is, the header.php file gets out and up the views folder and then descends all the way down to the style.css.

Thanks a million for all the efforts you have put in.

They have taught me a lot, I have learned about the structure of the web, I have learned about not using 'include' , about how to place and gather the assets elsewhere, so, it is been very helpful.

best regards


Alvaro
#40

[eluser]Aken[/eluser]
[quote author="alvaroeesti" date="1343168376"]

Got it:

What I did, is get the relative paths the proper way. I wrote this and it fetched it

Code:
&lt;style type='text/css' media='all'&gt;@import url('./css/style.css');&lt;/style&gt;
&lt;link rel='stylesheet' type='text/css' media='all' href=./css/style.css /&gt;

Note the 'dot' which is just climbing one directory above, that is, the header.php file gets out and up the views folder and then descends all the way down to the style.css.[/quote]

WRONG! This is still a relative URL! And you're still being redundant. Read my post, please.




Theme © iAndrew 2016 - Forum software by © MyBB