Linking to Stylesheets

#1
[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

#2
[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?

#3
[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

#4
[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...

#5
[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.

#6
[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"/>

#7
[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" />

#8
[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.

#9
[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.......

#10
[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.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.