Forums de discussion

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

SARITHA VASUDEV, modifié il y a 11 années.

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

New Member Publications: 3 Date d'inscription: 30/10/12 Publications récentes
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, modifié il y a 11 années.

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

Junior Member Publications: 94 Date d'inscription: 24/09/12 Publications récentes
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, modifié il y a 11 années.

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

New Member Publications: 3 Date d'inscription: 30/10/12 Publications récentes
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, modifié il y a 11 années.

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

Junior Member Publications: 94 Date d'inscription: 24/09/12 Publications récentes
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, modifié il y a 11 années.

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

Regular Member Publications: 145 Date d'inscription: 31/01/11 Publications récentes
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, modifié il y a 11 années.

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

New Member Publications: 3 Date d'inscription: 30/10/12 Publications récentes
Thanks both for the reply.. :-)
Anonymous Anonymous, modifié il y a 9 années.

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

Regular Member Publications: 127 Date d'inscription: 16/09/19 Publications récentes
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>