CodeIgniter Forums
Linking to Stylesheets - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: Linking to Stylesheets (/thread-34089.html)

Pages: 1 2


Linking to Stylesheets - El Forum - 09-18-2010

[eluser]Praveen A P[/eluser]
Hey Guys,

Need some help.

I have a view under the folder
Code:
system\application\views

Now I have some style sheets and javascripts that i plan to put in a folder say custom.

Let's say the folder is put under \application at the same level as views folder.

Now how do i refer the files in views I create?

Will this work?????

Code:
<link rel="stylesheet" type="text/css" href="http://localhost/ci/system/application/custom/css/custom/css/defaultStyle.css"/>
        [removed][removed]


Praveen


Linking to Stylesheets - El Forum - 09-18-2010

[eluser]Praveen A P[/eluser]
Guys,

Plz help me. I need to know this. Does nobobody know how to get across? Atleast the CI Creators?


Linking to Stylesheets - El Forum - 09-18-2010

[eluser]natefons[/eluser]
put it in main dir
htdocs

so:
htdocs/style.css

now when linking app
<link href="/style.css"

use the js same way

u can also put them inside a folder
htdocs (or public_html...w.e is ur root dir)/foldername/filename


hope that helps


Linking to Stylesheets - El Forum - 09-18-2010

[eluser]mi6crazyheart[/eluser]
Code:
<link rel="stylesheet" type="text/css" href="http://localhost/ci/system/application/custom/css/custom/css/defaultStyle.css"/>

Are u getting by using this as u've explained ? If not, then u can go ahead with u'r style else, generally its better to make an ASSET folder in the root directory where u've kept all u'r CI files. Then save all u'r CSS/JS file at there...


Linking to Stylesheets - El Forum - 09-18-2010

[eluser]Praveen A P[/eluser]
I have placed my css file under htdocs/ci

where ci is codeignitor root.

I have this code in the view class.

Code:
<link rel="stylesheet" type="text/css" href="defaultStyle.css"/>

Still no luck.

Please tell me how do I do it.


Linking to Stylesheets - El Forum - 09-18-2010

[eluser]Praveen A P[/eluser]
Forget everything, the code below does work.

Code:
<link rel="stylesheet" type="text/css" href="http://localhost/ci/system/application/custom/css/defaultStyle.css"/>



Linking to Stylesheets - El Forum - 09-18-2010

[eluser]natefons[/eluser]
yes the above code works...however, u will need to update the hrefs when u upload to a host.

if your style sheet is in htdocs/ci (so htdocs/ci/style.css)
your link will be

[code]
<link rel="stylesheet" type="text/css" href="/ci/style.css" />


Linking to Stylesheets - El Forum - 09-18-2010

[eluser]WanWizard[/eluser]
Move your application directory out of the system directory, and move your assets out of your application directory.

Most people use a /assets directory, in there you can create /css, /js and so on. You then create links like this:
Code:
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/css/defaultStyle.css"/>

which makes them independent of your application directory, and because you no longer hardcode your url's, fully portable.


Linking to Stylesheets - El Forum - 09-18-2010

[eluser]Praveen A P[/eluser]
[quote author="natefons" date="1284862382"]yes the above code works...however, u will need to update the hrefs when u upload to a host.

if your style sheet is in htdocs/ci (so htdocs/ci/style.css)
your link will be

[code]
<link rel="stylesheet" type="text/css" href="/ci/style.css" />[/quote]


NOPE that does not work. Did not work atleast on my machine.

Others, comments please.......


Linking to Stylesheets - El Forum - 09-18-2010

[eluser]Praveen A P[/eluser]
[quote author="WanWizard" date="1284862610"]Move your application directory out of the system directory, and move your assets out of your application directory.

Most people use a /assets directory, in there you can create /css, /js and so on. You then create links like this:
Code:
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/css/defaultStyle.css"/>

which makes them independent of your application directory, and because you no longer hardcode your url's, fully portable.[/quote]


Tried the base url thing which did not work. Let me try the other part.