Thank you so much Marius!  I've been trying to get this to work for several 
days.  Your suggestion provided me with exactly the result that I want. 

Thank you!

Naoufel

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of 
Marius Dumitru Florea
Sent: Monday, January 28, 2013 3:22 PM
To: XWiki Users
Subject: Re: [xwiki-users] Xwiki Enterprise 4.4: Using Velocity variables 
inside a custom CSS file

On Mon, Jan 28, 2013 at 6:43 PM, Naoufel Chbihi <[email protected]> 
wrote:
> Hello
>
> I have created a custom CSS file (/xwiki/skins/myskin/css/mystyle.css) 
> and I created a Velocity template to reference this css file 
> (/xwiki/skins/myskin/templates/customcss.vm).  Inside the Velocity 
> template, I have the line

> <link rel="stylesheet" href="$xwiki.getSkinFile('css/mystyle.css')"/>

<link rel="stylesheet" href="$xwiki.getSkinFile('css/mystyle.css', true)"/>

See 
http://nexus.xwiki.org/nexus/service/local/repositories/releases/archive/org/xwiki/platform/xwiki-platform-oldcore/4.4.1/xwiki-platform-oldcore-4.4.1-javadoc.jar/!/com/xpn/xwiki/api/XWiki.html#getSkinFile%28java.lang.String,%20boolean%29
. The second parameter ensures that the CSS files is served as a dynamic 
resource, and thus the Velocity code is parsed.

You should also put this at the start of your CSS file:

#template('colorThemeInit.vm')

Hope this helps,
Marius

> and it works fine.
> Now I want to able to use the $theme variable inside my CSS file to use 
> attributes like $theme.pageBackgroundColor and $theme.textColor;.  However, I 
> can't seem to get the theme variable to be passed into the CSS file.  All 
> references to these attributes return a null value inside the CSS file.
>
> In the customcss.vm file, I added the line $theme.menuLinkColor for debugging 
> purposes and it returns a non-null value.  So, I know that the value of this 
> variable is available within the Velocity template.
>
> Does anyone know how I can do this?
>
> Thank you.
>
> Naoufel Chbihi
> Technical Specialist | Spécialiste technique Mainframe Operating 
> System Technology | Technologie du système d'exploitation des 
> ordinateurs centraux Service Management & Delivery (SM&D) | Gestion et 
> prestation des services (GPS) Information Technology Services Branch 
> (ITSB) | Direction générale des services d'infotechnologie (DGSIT) 
> Shared Services Canada | Services partagés Canada 7038-700 Montreal 
> Road, Ottawa, ON K1A 0P7 | 7038-700, chemin Montréal, Ottawa, ON K1A 
> 0P7
> Tel.: 613-748-2169
> Fax: 613-748-2617
> E-mail: [email protected] | [email protected]
>
>
> _______________________________________________
> users mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to