12 replies [Last post]
jeffd
Offline
Regular
Hollywood, CA
Last seen: 13 years 47 weeks ago
Hollywood, CA
Joined: 2007-01-13
Posts: 20
Points: 0

Quick question. Just wondering if and how I could include a directory of CSS files. I know I can include multiple CSS files, but that requires linking each individual file. I was just wondering if there is a way I can set it to include ALL the CSS files from within a particular directory. In my case the directory is called CSS and there is about 4 or 5 CSS files within it.

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 7 years 39 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

You can't , but you could

You can't , but you could have one linked stylesheet that @imports the others

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

jeffd
Offline
Regular
Hollywood, CA
Last seen: 13 years 47 weeks ago
Hollywood, CA
Joined: 2007-01-13
Posts: 20
Points: 0

Hmm. Tell me more.

Hmm. Tell me more. Smile

I haven't used @import before :\

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 7 years 39 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

http://www.w3.org/TR/CSS21/ca

http://www.w3.org/TR/CSS21/cascade.html#at-import

A stylesheet file may contain just these and no other rulesets

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

jeffd
Offline
Regular
Hollywood, CA
Last seen: 13 years 47 weeks ago
Hollywood, CA
Joined: 2007-01-13
Posts: 20
Points: 0

Awesome. I got it work.

Awesome. I got it to work. Thanks for your help! Smile

jeffd
Offline
Regular
Hollywood, CA
Last seen: 13 years 47 weeks ago
Hollywood, CA
Joined: 2007-01-13
Posts: 20
Points: 0

Hmm. I thought it worked but

Hmm. I thought it worked but not to the extent I wanted it. I think something is screwed up because I am using includes.

>ROOT
>CSS
>>import.css
@import url("fonts.css");
@import url("inputs.css");
@import url("layouts.css");

>>fonts.css
>>inputs.css
>>layouts.css
>page1.php
>page1.html (imported from page1.php)

And the @import code, I've tried a few variations. Like, putting /css/ before the file name and etc. Maybe this helps explain the way the includes are setup.

page1.php > page1.html > import.css > fonts.css, inputs.css, layouts.css

I hope that made sense. Anyways. Everything is screwed up and not working correctly. I am getting weird things on the page like, "0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i"

Triumph (not verified)
Anonymous's picture
Guru

Hugo wrote:You can't

Hugo wrote:
You can't ...

How's about something like this:
<?php
exec('cd css/; ls -A .', $output, $return );
foreach ( $output as $file )
{
$test = explode(".",$file);
if ($test[1] == "css") {
echo '<link rel="stylesheet" type="text/css" href="'.$file.'" />' ."\n";
}
}
?>  

Laughing out loud

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 7 years 39 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

Yeah but that's cheating,

Yeah but that's cheating, anyways why dont you just use the various read dir functions dir()opendir() scandir()

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

Triumph (not verified)
Anonymous's picture
Guru

Hugo wrote:Yeah but that's

Hugo wrote:
Yeah but that's cheating, anyways why dont you just use the various read dir functions dir()opendir() scandir()

exec to me is like dl to you. Tongue

jeffd
Offline
Regular
Hollywood, CA
Last seen: 13 years 47 weeks ago
Hollywood, CA
Joined: 2007-01-13
Posts: 20
Points: 0

At this point maybe I should

At this point maybe I should explain why it's laid out this way.

These sites are built for clients, which they can edit through a web based HTML editor. We use the PHP page to define the layout of the page. The PHP file the clients can't touch. However they can edit the included HTML file, which is basically just text.

Also, I don't really know much PHP language. All I use it for is includes. :\

So I guess I'm asking for a little more in depth help.

I like the way its setup now with the @import and such. But I was just wondering if it isn't working correctly because I have the ../ or ./ or something screwed up.

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 7 years 39 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

not sure what's wrong, your

not sure what's wrong, your paths look correct you should see the files using /css/ or ../css/

The php code that you quote doesn't look like it's a problem todo with the css calls.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

jeffd
Offline
Regular
Hollywood, CA
Last seen: 13 years 47 weeks ago
Hollywood, CA
Joined: 2007-01-13
Posts: 20
Points: 0

Finally got it to work!

Finally got it to work! Smile

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 7 years 39 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

Good stuff, if it's not too

Good stuff, if it's not too much trouble could you just briefly round off the thread with an explanation of what the problem was, so others may possibly benefit, thanks.

Hugo.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me