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

[eluser]TWP Marketing[/eluser]
I would call the directory 'css' rather than 'assets'.
and the path should be relative

Instead of this:
Code:
<style type='text/css' media='all'>@import url('/assets/style.css');</style>

Use this: note I removed the root slash.
Code:
<style type='text/css' media='all'>@import url('assets/style.css');</style>

#12

[eluser]CroNiX[/eluser]
I always start my paths with / (which is relative to root, same as without)
http://yoursite.com/assets would be an absolute url as it includes the hostname
#13

[eluser]sith4life[/eluser]
pardon my confusion but why not use
Code:
<link rel="stylesheet" href="<?php echo base_url() ?>assets/style.css" type="text/css" />
in your header file? that will make the link an absolute path based on your
Code:
config['base_url']
#14

[eluser]CroNiX[/eluser]
You can, but if you have some pages in SSL and other that aren't, you will run into errors because you hardcoded "http" into the url.

If you just use
/assets/file.css, it will use http:// if on an http page or use https:// if on SSL.

I'd rather it be able to use either without having to tell it to for each of my assets. Then it works the same for my SSL checkout page as the non-SSL homepage with no alteration.
#15

[eluser]TWP Marketing[/eluser]
[quote author="CroNiX" date="1343158558"]I always start my paths with / (which is relative to root, same as without)
http://yoursite.com/assets would be an absolute url as it includes the hostname[/quote]

CroNix, thanks for the tip on usage. I've not had any problem with using it without the root slash.
(EDIT but I'm also not using SSL...)
I missed the possible .htaccess problem, never thought of it...
I hope that solves the OPs problem.
#16

[eluser]CroNiX[/eluser]
When using "assets/file.css", that's not relative to "root", it's relative to the file being called. In CI's case, it's ALWAYS the bootstrap file, which is index.php, due to how the framework is laid out. I just always got in the habit of starting with a /, which always means "relative to site root" as with other frameworks and traditional php websites, you can run into a lot of problems using relative paths since not everything is being processed through a single file, index.php.
#17

[eluser]alvaroeesti[/eluser]

yes about the relative vs absolute

I renamed it to css, it is better so that you can distinguish them from other assets.

As you can imagine, I did try variations about one slash, two, none etc no difference.

I have

--application folder

--css folder that I just created

--system folder

-- user guide folder

Then, inside application I go to views and that is where I have the header.php file, inside whose head I (copy and paste) have this:
Code:
<style type='text/css' media='all'>@import url('css/style.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='css/style.css' />

I tried the idea (which is a good one) of including this

Code:
<link rel="stylesheet" href="<?php echo base_url() ?>assets/style.css" type="text/css" />

but then the page went blank, it took me to I don't know where. I haven't modified the config file, so the base url is up to CI to guess.


#18

[eluser]alvaroeesti[/eluser]

I went to read the view source of the blank page and read



<link rel="stylesheet" href="<br />
<b>Fatal error</b>: Call to undefined function base_url() in <b>C:\xampp\htdocs\CI\application\views\header.html</b> on line <b>8</b><br />
#19

[eluser]sith4life[/eluser]
another option, the one I used to be specific is add this to the end of /application/config/config.php
Code:
/*
* ------------------------------------------------------------------------
*
*  Custom configurations
*
* ------------------------------------------------------------------------
*/
// default stylesheet for the application
$config['css'] = 'styles.css';
#20

[eluser]sith4life[/eluser]
[quote author="alvaroeesti" date="1343159601"]
I went to read the view source of the blank page and read



&lt;link rel="stylesheet" href="&lt;br />
<b>Fatal error</b>: Call to undefined function base_url() in <b>C:\xampp\htdocs\CI\application\views\header.html</b> on line <b>8</b><br />[/quote]

use have to load the url helper for that function to work. http://ellislab.com/codeigniter/user-gui...elper.html




Theme © iAndrew 2016 - Forum software by © MyBB