Fórum

Stylesheets in velocity?

Hugo Müller, modificado 14 Anos atrás.

Stylesheets in velocity?

Junior Member Postagens: 94 Data de Entrada: 25/09/09 Postagens Recentes
Hi @all,
i thought i have understand the liferay framework but now i have problems with velocity emoticon

As i understand the portal_normal.vm file is the overall site structure and generates the html code.
So i changed the variable '$the_title - $company_name' to my companyname.

Works fine after deployment.
Now i want to append a stylessheet

I inserted between <head></head> the following line:

<link href="../_resources/css/business.css" media="screen,projection" type="text/css" rel="stylesheet">

the Stylesheet is in --> /_diffs/_resources/css/

The styles didn't work. When i use fireburg it shows me the following:

<link href="../_resources/css/business.css" media="screen,projection" type="text/css" rel="stylesheet">
  
    
      <title></title>
      <meta content="1; url=http://localhost:8080/web/guest" http-equiv="refresh">
    

    

    <!--
        The numbers below are used to fill up space so that this works properly in IE.
        See http://support.microsoft.com/default.aspx?scid=kb;en-us;Q294807 for more
        information on why this is necessary.

       2312345678901234567890123456789012345678901234567890123456789012345678901234567890
       2412345678901234567890123456789012345678901234567890123456789012345678901234567890
       2512345678901234567890123456789012345678901234567890123456789012345678901234567890
       26-->

     
  




Where comes that shit of html code from???

There should be the commentary in the *.css file.
In that *.css file i import with the @import command other *.css files

Please, do you have any ideas what is going wrong? Maybe i can't use stylesheets directly in velocity?
I don't really want to change the top_head.jsp.

What can i do to use my stylesheets?

Thanks,
Best regards,
Hugo
thumbnail
Nikos Kapatos, modificado 14 Anos atrás.

RE: Stylesheets in velocity?

Junior Member Postagens: 57 Data de Entrada: 12/11/08 Postagens Recentes
The "../_resources/css/business.css" that u use looks in the root of the server and not the root folder of your theme.

Change it by either using the name of your theme "my_theme/css/something.css" or use velocity vars to get the name of the theme and use it in the path as a dynamic snippet for all your projects.

Or just import the css in custom.css file than using it in portal-normal.vm file

As for all this code I have an idea from where it comes from but trust me u don't want to know emoticon

P.S. About @import command. When u r in developer mode the @import("something.css"); works ok but if not u should remove quotes or else it will not work @import(something.css);
Hugo Müller, modificado 14 Anos atrás.

RE: Stylesheets in velocity?

Junior Member Postagens: 94 Data de Entrada: 25/09/09 Postagens Recentes
Yeah, thanks man. It works emoticon

I use the $themeDisplay.getThemeRootPath() .
But how do i now which Java mathods i can use?
i first tried $theme.getThemePath(). But there i got nothing.
Are there some Hints in VelocityVariables.java which Methods from Klasses could be used?


As for all this code I have an idea from where it comes from but trust me u don't want to know emoticon


Hehe. Ok ;)

That with @import i don't understand.

I use @import url ('css/mystyle.css');
Is that ok ?
Thanks very much
Hugo
thumbnail
Lisa Simpson, modificado 14 Anos atrás.

RE: Stylesheets in velocity?

Liferay Legend Postagens: 2034 Data de Entrada: 05/03/09 Postagens Recentes
It should look exactly like this...

@import url(base.css);

@import url(reset.css);

@import url(nav_portlet.css);

@import url(calendar.css);
Naven Pathange, modificado 13 Anos atrás.

RE: Stylesheets in velocity?

New Member Postagens: 11 Data de Entrada: 27/04/09 Postagens Recentes
To access a style sheet in portal_normal.vm, set the css path to a velocity variable in init_custom.css.vm
For example:

#set ($samp_css_file = $portalUtil.getStaticResourceURL($request, "$css_folder/samp_file.css"))


Then u can import this in portal_normal.vm as shown below,

#css ($samp_css_file)

inside the head section of portal_normal.vm
Gilad Reich, modificado 7 Anos atrás.

RE: Stylesheets in velocity?

New Member Postagens: 10 Data de Entrada: 21/07/16 Postagens Recentes
Naven Pathange:
To access a style sheet in portal_normal.vm, set the css path to a velocity variable in init_custom.css.vm
For example:

#set ($samp_css_file = $portalUtil.getStaticResourceURL($request, "$css_folder/samp_file.css"))


Then u can import this in portal_normal.vm as shown below,

#css ($samp_css_file)

inside the head section of portal_normal.vm


My apologies for dummy question, pretty new to Freemarker syntax. Would it be safe doing in freemarker so?:
    &lt;#include ($sample_css_file) /&gt;

Or would i need somehow to define that it's a css file? like in velocity that you type that it's a css file.
Gilad Reich, modificado 7 Anos atrás.

RE: Stylesheets in velocity?

New Member Postagens: 10 Data de Entrada: 21/07/16 Postagens Recentes
Forgot to mention that i already found a solution for that in Liferay source code:
VM_liferay.vm
FTL_liferay.ftl

You can find all macros in these files and understand what kind of liferay macros you can use in your template files.

So to answer my question:
Velocity:
&lt;#include ($sample_css_file) /&gt;

Freemarker:
&lt;@liferay.css sample_css_file /&gt;