Forums

Home » Liferay Portal » English » 2. Using Liferay » General

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
SARITHA VASUDEV
How to include CSS & JS files in Web Content source?
October 30, 2012 6:16 AM
Answer

SARITHA VASUDEV

Rank: New Member

Posts: 3

Join Date: October 30, 2012

Recent Posts

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.
Pavel Savinov
RE: How to include CSS & JS files in Web Content source?
October 30, 2012 7:43 AM
Answer

Pavel Savinov

Rank: Junior Member

Posts: 97

Join Date: September 24, 2012

Recent Posts

Hi.

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

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


CSS:
1<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
RE: How to include CSS & JS files in Web Content source?
October 30, 2012 8:31 AM
Answer

SARITHA VASUDEV

Rank: New Member

Posts: 3

Join Date: October 30, 2012

Recent Posts

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?
Pavel Savinov
RE: How to include CSS & JS files in Web Content source?
October 30, 2012 9:26 AM
Answer

Pavel Savinov

Rank: Junior Member

Posts: 97

Join Date: September 24, 2012

Recent Posts

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...
Gaurav Jain
RE: How to include CSS & JS files in Web Content source?
October 30, 2012 12:11 PM
Answer

Gaurav Jain

Rank: Regular Member

Posts: 146

Join Date: January 31, 2011

Recent Posts

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
RE: How to include CSS & JS files in Web Content source?
October 30, 2012 9:43 PM
Answer

SARITHA VASUDEV

Rank: New Member

Posts: 3

Join Date: October 30, 2012

Recent Posts

Thanks both for the reply.. :-)
enayath ulla
RE: How to include CSS & JS files in Web Content source?
August 14, 2014 5:58 AM
Answer

enayath ulla

Rank: Junior Member

Posts: 64

Join Date: July 15, 2013

Recent Posts

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>