Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Akram MONCER
add javascript/image file to hook
November 19, 2012 3:06 AM
Answer

Akram MONCER

Rank: Regular Member

Posts: 106

Join Date: September 25, 2012

Recent Posts

hi
can anyone help, i want to add some js file and image in my hook projetct i test a simple reference like in html "<img src="/image/img/png"/> but i didn't work
thanks
Hitoshi Ozawa
RE: add javascript/image file to hook
November 19, 2012 3:17 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

You have to prepend portlet name to the url of the file. It's possible to manually enter the portlet name, but the common practice is to dynamically insert it as below:
<img src="<%= request.getContextPath() %>/image/img/image.png" />
Akram MONCER
RE: add javascript/image file to hook
November 19, 2012 3:21 AM
Answer

Akram MONCER

Rank: Regular Member

Posts: 106

Join Date: September 25, 2012

Recent Posts

thanks for your replay, i try your solution but don't work
Hitoshi Ozawa
RE: add javascript/image file to hook
November 19, 2012 4:46 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

Sorry, you were creating a hook and not a portlet.
Where is the image located? In the ROOT\html\icons or in your hook? Have you tried hard-coding the portlet name.

Try
img src="/html/icons/admin_server.png"
Akram MONCER
RE: add javascript/image file to hook
November 19, 2012 5:47 AM
Answer

Akram MONCER

Rank: Regular Member

Posts: 106

Join Date: September 25, 2012

Recent Posts

your solution works but i want to put the image in the hook and not in the icons file, and it's a hook for the shopping portlet
Akram MONCER
RE: add javascript/image file to hook
November 19, 2012 6:05 AM
Answer

Akram MONCER

Rank: Regular Member

Posts: 106

Join Date: September 25, 2012

Recent Posts

thank you very much for giving me the solution i just have to put all the path to the image it mean : /html/..../image.png