Forum OpenACS Q&A: Re: Arbitrary Template File Extensions

Collapse
Posted by Dirk Gomez on
Why do you want to do this? Isn't it widely accept that a file with the extention .css is a css file, whereas (less widely accepted) an .adp file is an adp file?
Collapse
Posted by Ralph Hempel on
Well, if a user asks for the file:

  www.myserver.com/section/index

and the index file links to:

  www.myserver.com/section/css/screen.css

I want the css file to pass through the templating system so that it can have certain values for colour or formatting updated by the template system.

Maybe I'm missing something really obvious here, but how else can I do this besides forcing OpenACS to process my css file as if it was an adp file?

Collapse
Posted by Dirk Gomez on

Why don't you put a such a line into your respective adp file?:

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

That should do it for you

Collapse
Posted by Ralph Hempel on
I think the problem with your method is that the screen.css will not be processed by the template system...

I know how to link to stylesheets, what I want to do is have the stylesheet pass through the template system.

Am I missing something glaringly obvious?

Collapse
Posted by Vinod Kurup on
Hi Ralph,

I'm still not 100% clear what you're trying to do, but let me give it a shot.

You have <p class="foo"> in your index.adp file. You want the "foo" class to be blue in some circumstances and orange in other circumstances. So when index.adp links out to screen.css, you want screen.css to be built dynamically with the "foo" class set to the proper color.

I'm not sure this is the best way to handle it. Don't browsers cache css files? If so, then your sites might not look right. I think a better way would be to change the class name in the index file and have extra classes defined in your css file for the various sections. so <p class="foo-1"> for section 1 and <p class="foo-2"> for section 2, then define each of those classes in the css file.

Of course, I may be completely misinterpreting your question, in which case it might be best to re-explain and show the source of each of the files in question.

Collapse
Posted by Ralph Hempel on
Vinod,

I guess in general, what I want to have is a way of telling OpenACS to use extension "xyz" in exactly the same way as if it was an "adp" file.

The browser asks for "screen.css" and my (ideal) OpenACS server says, hmmm, I'd better run this through the template system and return screen.css with all of the variables set to the new values.

This part of your description is almost right...

You have <p class="foo"> in your index.adp file. You want the "foo" class to be blue in some circumstances and orange in other circumstances. So when index.adp links out to screen.css, you want screen.css to be built dynamically with the "foo" class set to the proper color.

In fact, I'll have one set of pages on my website where foo is blue, and another set of pages where foo is orange. They don;t change on a single page. Depending on where in the tree the index.adp file is, it will link in a different screen.css file with the colour attribute set appropriately.

Being a lazy programmer, and realizing that my css files are almost identical, and not wanting to synchronize them, I through that passing them through the template system might do what I want.

I _could_ just write up a tcl script that uses a master screen.css file and writes out the site dependent screen.css files as needed....