Forums

Home » Liferay Sync

Combination View Flat View Tree View
Threads [ Previous | Next ]
Rewati Raman
how to include javascript code in portal_normal.vm
June 14, 2012 7:06 AM
Answer

Rewati Raman

Rank: Junior Member

Posts: 97

Join Date: February 24, 2012

Recent Posts

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
RE: how to include javascript code in portal_normal.vm
June 14, 2012 10:11 AM
Answer

Kavita Gupta

Rank: Junior Member

Posts: 64

Join Date: March 12, 2008

Recent Posts

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
Rewati Raman
RE: how to include javascript code in portal_normal.vm
June 14, 2012 9:00 PM
Answer

Rewati Raman

Rank: Junior Member

Posts: 97

Join Date: February 24, 2012

Recent Posts

thanks kavita
Hitoshi Ozawa
RE: how to include javascript code in portal_normal.vm
June 14, 2012 3:50 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7990

Join Date: March 23, 2010

Recent Posts

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>
Rewati Raman
RE: how to include javascript code in portal_normal.vm
June 14, 2012 8:59 PM
Answer

Rewati Raman

Rank: Junior Member

Posts: 97

Join Date: February 24, 2012

Recent Posts

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
Amit Doshi
RE: how to include javascript code in portal_normal.vm
June 15, 2012 12:32 AM
Answer

Amit Doshi

Rank: Liferay Master

Posts: 543

Join Date: December 29, 2010

Recent Posts

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 :-

1<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 :-

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


Hope I am clear.

Regards,
Amit Doshi
Rewati Raman
RE: how to include javascript code in portal_normal.vm
June 15, 2012 8:10 PM
Answer

Rewati Raman

Rank: Junior Member

Posts: 97

Join Date: February 24, 2012

Recent Posts

thanks Amit,

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

Regards
Rewati Raman.