Foros de discusión

How to include CSS & JS files in Web Content source?

SARITHA VASUDEV, modificado hace 11 años.

How to include CSS & JS files in Web Content source?

New Member Mensajes: 3 Fecha de incorporación: 30/10/12 Mensajes recientes
Hi All,

I have a query regarding Web Content . Can we include CSS or JS file in the WebContent HTML Source Code ? If yes, where to keep the files & how to give the reference?

NOTE : Without referring from themes ?

Also, can I give reference from any existing application in my webapps folder of liferay istallation?

Thanks in advance.
thumbnail
Pavel Savinov, modificado hace 11 años.

RE: How to include CSS & JS files in Web Content source?

Junior Member Mensajes: 94 Fecha de incorporación: 24/09/12 Mensajes recientes
Hi.

Of course you can include any external CSS and JS files in your web content, like this:

JS:
<script src="http://www.somehost.com/js/script.js"></script>


CSS:
<link rel="stylesheet" href="http://www.somehost.com/css/style.css" type="text/css">


Or you mean including CSS and JS from the other portlets?
SARITHA VASUDEV, modificado hace 11 años.

RE: How to include CSS & JS files in Web Content source?

New Member Mensajes: 3 Fecha de incorporación: 30/10/12 Mensajes recientes
Thanks for the reply , Pavel.

My question is , is this the best way to refer CSS/JS in Web Content ?

I have around 15 files (CSS & JS). And this application of mine will get deployed in 4 environments/hosts. So as per your answer, I have to create 4 files(HTML to update in Web Content) with CSS/JS pointing to the respective hosts. Could you please suggest, is there any other better way to refer CSS / JS files in Web Content rather than hard coding?
thumbnail
Pavel Savinov, modificado hace 11 años.

RE: How to include CSS & JS files in Web Content source?

Junior Member Mensajes: 94 Fecha de incorporación: 24/09/12 Mensajes recientes
Hm..You can create some templates with all required combinations of JS/CSS. And then create a web content with those templates, but in fact it will be very similiar...
thumbnail
Gaurav Jain, modificado hace 11 años.

RE: How to include CSS & JS files in Web Content source?

Regular Member Mensajes: 145 Fecha de incorporación: 31/01/11 Mensajes recientes
you may keep all the css/js files in your document library (so downlaod external files and upload to Document and media to some specific location); and then you may now use these urls of your document media of these files into web-content.

Alternatively you may copy these files to your theme, and then you an use your theme path in web-content for these files.
SARITHA VASUDEV, modificado hace 11 años.

RE: How to include CSS & JS files in Web Content source?

New Member Mensajes: 3 Fecha de incorporación: 30/10/12 Mensajes recientes
Thanks both for the reply.. :-)
Anonymous Anonymous, modificado hace 9 años.

RE: How to include CSS & JS files in Web Content source?

Regular Member Mensajes: 127 Fecha de incorporación: 16/09/19 Mensajes recientes
What if we have css and js files in our document and media under a folder exapmle:folder1

is this works fine?

<script type="text/javascript" src="$jquery_min_js.getData()"> script>
<script type="text/javascript" src="$external_js.getData()"> script>