You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Magnus ?or Torfason <ma...@handtolvur.is> on 2000/12/12 14:26:11 UTC

Using stylesheets with Velocity

Hi, 

I want each of my velocity screen templates to be able to
specify a stylesheet to use, what I want is essentially

<head>

<title>My Title</title>

<!-- The following line is what I need. -->
<link href="/mywebapp/mystylesheet.css" rel="stylesheet">

</head>

I'm guessing it has something to do with $page, but have
not found any documentation on it's use.

Thanks for any assistance.

RE: Using stylesheets with Velocity

Posted by Magnus ?or Torfason <ma...@handtolvur.is>.
> 
> I guess you meant within the Turbine environment... So your
> post went sort of to the wrong list.
> 

Hey, and I subscribed to this list just so that my fellow
Turbiners wouldn't scream at me for posting a Velocity 
question to the turbine list :(

Thanks anyway, your response was very helpful.

Magnus Torfason

Re: Using stylesheets with Velocity

Posted by Christoph Reck <Ch...@dlr.de>.
I guess you meant within the Turbine environment... So your
post went sort of to the wrong list.

Re: Using stylesheets with Velocity

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Magnus ?or Torfason wrote:
> 
> Hi,
> 
> I want each of my velocity screen templates to be able to
> specify a stylesheet to use, what I want is essentially
> 
> <head>
> 
> <title>My Title</title>
> 
> <!-- The following line is what I need. -->
> <link href="/mywebapp/mystylesheet.css" rel="stylesheet">
> 
> </head>
> 
> I'm guessing it has something to do with $page, but have
> not found any documentation on it's use.
> 
> Thanks for any assistance.

This is the velocity list, and I assume this is a Turbine question? 
There are lots of Turbiners slinking around, but still.  We like at
least to pretend... :)

If not a Turbine question, and indeed a Velocity question, put the css
you want to use into the context in  your app or servlet :

  context.put("css", "mystylesheet1.css" ); 

Do what you need to do with the second arg above. (if you have some
object, drop it in and invoke the method in the template...)

If you do as above, then in your template

  <link href="/mywebapp/$css" rel="stylesheet">

should do the trick.

geir

-- 
Geir Magnusson Jr.                               geirm@optonline.com
Velocity : it's not just a good idea. It should be the law.
http://jakarta.apache.org/velocity

Re: Using stylesheets with Velocity

Posted by Christoph Reck <Ch...@dlr.de>.
My previous response was ripped apart (due to the contained 
line starting with From), here it is again in full beauty:

I guess you meant within the Turbine environment... So your
post went sort of to the wrong list.

:From Velocity point of view, if that's the output you want, just
write it so ;)

Within Turbine, it depends if you are using the VelocityECSLayout
or the VelocityOnlyLayout.

a) For the ECS Layout you use:
   #set $page.StyleSheet = $content.("mystylesheet.css")
  (Note I'm reffering to the new ContentURI class added last
   friday to turbine and to the context.)

b) For the VelocityOnlyLayout you would need to do this
   by hand. Rafal Krzewski is preparing a HeadTool and a sample 
   layout template for this purpose. 
   See the "Script into HTML-Head" thread in the turbine list. 

:) Christoph


Magnus ?or Torfason wrote:
> 
> Hi,
> 
> I want each of my velocity screen templates to be able to
> specify a stylesheet to use, what I want is essentially
> 
> <head>
> 
> <title>My Title</title>
> 
> <!-- The following line is what I need. -->
> <link href="/mywebapp/mystylesheet.css" rel="stylesheet">
> 
> </head>
> 
> I'm guessing it has something to do with $page, but have
> not found any documentation on it's use.
> 
> Thanks for any assistance.