留言板

how to include javascript code in portal_normal.vm

thumbnail
Rewati Raman,修改在11 年前。

how to include javascript code in portal_normal.vm

Junior Member 帖子: 97 加入日期: 12-2-24 最近的帖子
i had designed the page using simple html5/css3 and javascript concepts without using liferay
now i want to integrate that web page specially the javascript codes that i had written in the portal_normal.vm into the theme........
i m not getting the appropriate solution to include Jquery library js file and other js files to the theme......
is there any solutions for that
Kavita Gupta,修改在11 年前。

RE: how to include javascript code in portal_normal.vm

Junior Member 帖子: 64 加入日期: 08-3-12 最近的帖子
Hi,

You can directly include js in portal_normal.vm as you are doing with normal html.

You can use <script src ... > to include the js.

Regards,
Kavita
thumbnail
Rewati Raman,修改在11 年前。

RE: how to include javascript code in portal_normal.vm

Junior Member 帖子: 97 加入日期: 12-2-24 最近的帖子
thanks kavita
thumbnail
Hitoshi Ozawa,修改在11 年前。

RE: how to include javascript code in portal_normal.vm

Liferay Legend 帖子: 7942 加入日期: 10-3-24 最近的帖子
Just add the following

<head>
<title>$the_title - $company_name</title>
$theme.include($top_head_include)
<script src="/html/js/jquery/custom/jquery-1.7.2.min.js"></script>
<script src="/html/js/jquery/custom/jquery-ui-1.8.21.custom.min.js"></script>
<link type="text/css" href="/html/css/smoothness/jquery-ui-1.8.21.custom.css" rel="stylesheet"/>
</head>
thumbnail
Rewati Raman,修改在11 年前。

RE: how to include javascript code in portal_normal.vm

Junior Member 帖子: 97 加入日期: 12-2-24 最近的帖子
thanks hitoshi but we dont have js folder inside html so do we need to create the folders in that structure but by default in theme we have js folder inside the dockroot only and for writing javascript we have main.js inside js folder so do we need to write anything inside main.js.......
thanks again for replying
thumbnail
Amit Doshi,修改在11 年前。

RE: how to include javascript code in portal_normal.vm

Liferay Master 帖子: 550 加入日期: 10-12-29 最近的帖子
Hi Rewati,

When you create the theme or the portlet with the help of ANT or MAVEN, it will default create the Structure for you.

You will have js,css,html,images etc. folder inside it. So put all the js files in the JS folder, images inside images folder etc.

So if you use in theme, then you can directly access with the help of $javascript_folder(it will use you the path upto javascript) .

So if you are using main.js then in the theme just need to write as below :-

<script type="text/javascript" src="$javascript_folder/main.js"></script>


And same way for the other JS files in theme.
For more details check this.

In the portlet you can use as below :-


<script type="text/javascript" src="<%=themeDisplay.getPathThemeJavaScript()%>/main.js"></script>


Hope I am clear.

Regards,
Amit Doshi
thumbnail
Rewati Raman,修改在11 年前。

RE: how to include javascript code in portal_normal.vm

Junior Member 帖子: 97 加入日期: 12-2-24 最近的帖子
thanks Amit,

I think my Problem got solved now....i have to try it out

Regards
Rewati Raman.
thumbnail
Omar Samir,修改在8 年前。

RE: how to include javascript code in portal_normal.vm

Junior Member 帖子: 29 加入日期: 15-5-19 最近的帖子
Hello Rewati

please ,, can you tell me what's the full path of folder that include js files and the full path of portal_normal.vm file ????