cancel
Showing results for 
Search instead for 
Did you mean: 

CSS include not loading

drozes
Champ in-the-making
Champ in-the-making
Hi guys;

One of my custom webscripts is grabbing a bunch of files and construction a website out of them.
(example.  in a component folder, i have head.html, nav.html and footer.html).

The site source looks exactly as it should.
The head.html links some CSS files - which when clicked loads the css document as expected.

***The issue - Although it appears the CSS file was linked correctly -  none of the css rules are being applied.  firebug itself says there are no rules for that file.

Anyone have an idea of what is happening?


//Sample source of the render webpage from my webscript.



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
   <head>
   <!–  HEADER COMPONENT –>
   <title>Sample Customization</title>
   <link rel="stylesheet" href="/testing-site-custom/css/style.css" type="text/css" media="screen" />


   </head>
<body>
   <div class="header">
      Header Stuff
   </div>
   <div class="navigation">
      <ul>
         <li>Home</li>
         <li>Section1</li>
         <li>Section 2</li>
      </ul>
   </div>
   
   <div id="wrapper">
      <p>tests Is this working?</p>
   <div>


   <div class="footer">

      Footer Content

   </div>

</body>
</html>
11 REPLIES 11

scouil
Star Contributor
Star Contributor
Is your server accessible from the outside so that we can see for ourselves?

Otherwise:
- Try clear your browser cache
- Monitor the "network" tab in firebug and check that the css file is correctly loaded.

drozes
Champ in-the-making
Champ in-the-making
Unforunitly my company doesn't allow us to open ports.

Tried both your suggestions already with no luck.

Thank you very much for your effort though!

drozes
Champ in-the-making
Champ in-the-making
The CSS file is located in the Document Repo.  When someone goes to the url, it get's served up through a template for a css file.

Could this be an issue?  The browser itself can navigate to the file - which tells me this shouldn't be an issue.

drozes
Champ in-the-making
Champ in-the-making
So because the CSS is being deliveried through a template, it seems that it is setting the content-type as text/html - where I'll need it to be text/css.

Does anyone have a suggestions of how to configure this? Setting headers in my template?

scouil
Star Contributor
Star Contributor
You can try to import it via freemarker.
Since it'll be included in your html it shouldn't cause any problem.
But you won't see it as a distinct file anymore.

drozes
Champ in-the-making
Champ in-the-making
Thanks for the reply Scouil,

Unfortunately that solution won't work for me.  There may be 7-9 css files and need to ensure we keep our source code as clean as possible. 

Thanks for the reply though!

scouil
Star Contributor
Star Contributor
The code will be as clean. With files separated the same in your file system.
Actually it might even be cleaner since you can the externalize some text/path/etc.

It's just that if you browse the source code with your web browser everything will be appended.

drozes
Champ in-the-making
Champ in-the-making
Yup, I agree the actual source will be very clean.

But need to keep CSS external - it allows the user's to cache common css files and it reduces load times.

thanks agian though for your efforts!

rdanner
Champ in-the-making
Champ in-the-making
If the CSS is loading from a webscript but not taking effect it is most likely due to the mimetype.  If the mimetype is not set properly in the response header it will not work in most browsers (assuming the extension is not .css on the url)

You can register custom mimetypes with share/alfresco/webscripr container

in a spring context file in share or alfresco:


   <bean parent="webscripts.formatmap">
      <property name="formats">
         <props>
            <prop key="css">text/css</prop>
         </props>
      </property>
   </bean>

Then set your webscript type to CSS