Foren

how to include jquery plugins in our own theme

thumbnail
path finder liferay, geändert vor 14 Jahren.

how to include jquery plugins in our own theme

Expert Beiträge: 262 Beitrittsdatum: 18.09.09 Neueste Beiträge
hello everyone,

Is it possible to include jQuery plugins(js files) in our theme and use it in our portlets without calling that js file in our portlet

my observation:
when we want to use jquery in our portlet for example table sorter we need to include
script src="path/to/js/file.jsp" is it possible that i can include through themes without giving this src in each of our portlets..

please help me to get out of this issue...


Thank you,

Regards,
Path Finder
Babu Janarthanan, geändert vor 14 Jahren.

RE: how to include jquery plugins in our own theme

Regular Member Beiträge: 128 Beitrittsdatum: 31.07.08 Neueste Beiträge
Hi,
you can include the JS files in portal_normal.vm as mentioned below.

#js ("$javascript_folder/xx/xx/sample.js")

hope it helps you.

Thx,
Babu
thumbnail
path finder liferay, geändert vor 14 Jahren.

RE: how to include jquery plugins in our own theme

Expert Beiträge: 262 Beitrittsdatum: 18.09.09 Neueste Beiträge
Babu Janarthanan:
Hi,
you can include the JS files in portal_normal.vm as mentioned below.

#js ("$javascript_folder/xx/xx/sample.js")



in which part do i have to include this line...
in body??
Babu Janarthanan, geändert vor 14 Jahren.

RE: how to include jquery plugins in our own theme

Regular Member Beiträge: 128 Beitrittsdatum: 31.07.08 Neueste Beiträge
inside head tag.

<head>
#js ("$javascript_folder/xx/xx/sample.js")
</head>
thumbnail
path finder liferay, geändert vor 14 Jahren.

RE: how to include jquery plugins in our own theme

Expert Beiträge: 262 Beitrittsdatum: 18.09.09 Neueste Beiträge
Babu Janarthanan:
inside head tag.

<head>
#js ("$javascript_folder/xx/xx/sample.js")
</head>


Thanks Babu it worked when i included in your way...
thumbnail
Pravin Pawar, geändert vor 14 Jahren.

RE: how to include jquery plugins in our own theme

Junior Member Beiträge: 62 Beitrittsdatum: 17.11.09 Neueste Beiträge
You can include it in head part like below...


      #js ("/html/themes/my-theme/javascript/home.js")



So it will be converted like below in your generated HTML

<script src="/html/themes/my-theme/javascript/home.js" type="text/javascript"></script>
thumbnail
path finder liferay, geändert vor 14 Jahren.

RE: how to include jquery plugins in our own theme

Expert Beiträge: 262 Beitrittsdatum: 18.09.09 Neueste Beiträge
Pravin Pawar:
You can include it in head part like below...


      #js ("/html/themes/my-theme/javascript/home.js")





Thanks Pravin for your quick reply
as u said i've included that line in portal_normal.vm as shown below


	<title>$the_title - Datatreis</title>

	$theme.include($top_head_include)
	#js ("/html/themes/threePL/javascript/jquery.tablesorter.js")



but nothing seems to be working.... please help me
thumbnail
Prakash Khanchandani, geändert vor 12 Jahren.

RE: how to include jquery plugins in our own theme

Expert Beiträge: 329 Beitrittsdatum: 10.02.11 Neueste Beiträge
Hi,

Thanks.

It worked for me, when I used this:
#js ("$javascript_folder/xx/xx/sample.js")

where $javascript_folder evaluates to the path to your javascript folder,
for eg:
If my javascript folder is javascript in docroot/_diffs/javascript/sample.js

then I would have the code in my portal_normal.vm like this:


#js ("$javascript_folder/sample.js")


and if the folder is docroot/_diffs/javascript/others/againothers/sample.js
then the code would be:


#js ("$javascript_folder/others/againothers/sample.js")

thumbnail
Rewati Raman, geändert vor 11 Jahren.

RE: how to include jquery plugins in our own theme

Junior Member Beiträge: 97 Beitrittsdatum: 24.02.12 Neueste Beiträge
nice post...very helpful