How to include CSS file in JSP Liferay
Add this line in liferay-portlet.xml <header-portlet-css>/css/yourcssname.css</header-portlet-css>
(or)
include this line in JSP
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/yourcssname.css"/>
include css in liferay theme(portal_normal.vm) ------> _diffs/templates/portal_normal.vm
<link href="$css_folder/main.css" rel="stylesheet">
How to include JS file in JSP Liferay
Add this line in liferay-portlet.xml
<footer-portlet-javascript>/js/yourjsnamel.js</footer-portlet-javascript>
(or)
include this line in JSP
<script src="<%=request.getContextPath()%>/js/yourjsname.js" ></script>
(or)
include js in liferay theme(portal_normal.vm) ------> _diffs/templates/portal_normal.vm
<script src="$javascript_folder/jquery.min.js"></script>
How to call an image in css:
background: url(../img/closeButton_over.gif) left top no-repeat;
How to call an image from jsp in Liferay
<img src="<%=request.getContextPath()%>/images/banner_1.jpg"/>
How to change the logo in Liferay Theme(How to cal an image VM file )
Inside templates you have portal_normal VM file.Open that file and change like
<img src="$images_folder/logo/logo.jpg" alt="logo" />
(OR)
<img src="$themeDisplay.getPathThemeImages()//logo/logo.jpg" width="960" />
Note: Better way is adding .js files and .css files in liferay-portlet.xml if you are using multiple times in portlet.
If you are using in multiple portlets better to add in theme level in portal_normal.vm
Add this line in liferay-portlet.xml <header-portlet-css>/css/yourcssname.css</header-portlet-css>
(or)
include this line in JSP
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/yourcssname.css"/>
include css in liferay theme(portal_normal.vm) ------> _diffs/templates/portal_normal.vm
<link href="$css_folder/main.css" rel="stylesheet">
How to include JS file in JSP Liferay
Add this line in liferay-portlet.xml
<footer-portlet-javascript>/js/yourjsnamel.js</footer-portlet-javascript>
(or)
include this line in JSP
<script src="<%=request.getContextPath()%>/js/yourjsname.js" ></script>
(or)
include js in liferay theme(portal_normal.vm) ------> _diffs/templates/portal_normal.vm
<script src="$javascript_folder/jquery.min.js"></script>
How to call an image in css:
background: url(../img/closeButton_over.gif) left top no-repeat;
How to call an image from jsp in Liferay
<img src="<%=request.getContextPath()%>/images/banner_1.jpg"/>
How to change the logo in Liferay Theme(How to cal an image VM file )
Inside templates you have portal_normal VM file.Open that file and change like
<img src="$images_folder/logo/logo.jpg" alt="logo" />
(OR)
<img src="$themeDisplay.getPathThemeImages()//logo/logo.jpg" width="960" />
Note: Better way is adding .js files and .css files in liferay-portlet.xml if you are using multiple times in portlet.
If you are using in multiple portlets better to add in theme level in portal_normal.vm
Those who do not remember the past are condemned to repeats it. See the link the below for more info.
ReplyDelete#repeats
www.ufgop.org
It worked, thanks
ReplyDeleteit really worked. thanks.
ReplyDeletei am new to liferay. i want to add js file in my all page available. my question is
ReplyDelete1. where i have uploaded the .js file and .css to server(path)
2.i uploading the files .js and .css then how to add these files to my portlet.
3. where i can found the theme and portlet .xm.
html code examples
ReplyDeletehtml css image tag src specifies a URL
thank you it worked
ReplyDelete