Welcome Guest, Not a member yet? Register   Sign In
CSS and File Structure
#1

[eluser]PPhunky[/eluser]
Greetings All,
I am new to CodeIgniter. I want to create a style sheets for views. I cannot get the style.css to affect the view. I have the following File Structure. Thanks in advance for the support.. :-)

Here is my | Base Site URL

$config['base_url'] = "http://www.website.com/dev/project/";


here is the link I am trying to use:
<link type="text/css" rel="stylesheet" href="assets/css/style.css"/>




dev -
Project
application
config
controllers
errors
...
views

Assets
css
images
js

System

user_guide
#2

[eluser]Dan Bowling[/eluser]
Are you using .htaccess to rewrite URIs? If os, your base url is going to be changing depending on your controller.

Here's what I use:

<style type="text/css" media="screen">@import "<?php echo base_url(); ?>/system/application/views/css/screen.css";</style>
#3

[eluser]PPhunky[/eluser]
thanks for the reply.. I am not using htaccess
#4

[eluser]Dan Bowling[/eluser]
well, if you aren't using htaccess, then the thing that would be affecting it would be just the relative URI of your index.php file.

Like I said though, the base_url() function can make it really easy to make everything go with the way you have your config file set up.
#5

[eluser]PPhunky[/eluser]
Ok, I'll read up on the base_url().. I am basically a design person learning CI in order to do a proof of concept on a project..

are all links based out of the location of the index.php file..


for example, if I have my asset folder in the same directory as index.php


should the link be asset/css/style.css

thanks again for your time..

it's greatly appreciated..
#6

[eluser]Dan Bowling[/eluser]
Yes, everything is based off the index.php directory. It's because every page request goes through that single file, then the rest of the information is in the query string (which doesn't affect the folder structure--unless you rewrite it.)

I highly recommend using the base_url() feature because it lets you do rewriting later, without having to fix all your templates. It also keeps things consistent, since you need to be updating that configuration option as you move your install anyways.

Another option that just appeared is here: http://ellislab.com/forums/viewthread/45055/ It's a plugin that does some of this for you.

I understand where you are coming from... I was a designer who needed to have a faster and more secure way to do PHP. CI has made me a much better programmer. It just takes some time to learn, as always.
#7

[eluser]jedd[/eluser]
Here's the code from my view:

Code:
echo  link_tag('assets/stylesheets/'. $theme .'.css');

Which lets me swap CSS based on user's theme .. but the point is link_tag() is a handy function to use here.

The above code comes out, at the browser, as :

Code:
<link  href="http://localhost/devel/pdb3/assets/stylesheets/green.css" rel="stylesheet" type="text/css" />

link_tag() uses the same logic as base_url() to calculate the real location of the file, so it's pretty painless.
#8

[eluser]PPhunky[/eluser]
Ok.. I'll keep at it.. let me try this..




Theme © iAndrew 2016 - Forum software by © MyBB