掲示板

Accessing theme images in WCM templates

thumbnail
11年前 に Chris Becker によって更新されました。

Accessing theme images in WCM templates

Regular Member 投稿: 112 参加年月日: 10/06/11 最新の投稿
Hi everyone;

I am using Liferay 6.1 edition in a JBoss app-server environment.

Can anyone tell me how to access images stored in a theme's image folder from within a WCM Velocity template?

I am creating a WCM template that contains a form, and I wish to use an image for the Submit button. I would like to store that button image within the theme, and just reference via a Velocity variable, or at least a Velocity variable that gives me the image directory of the theme and then just append the image name to it.

Any guidance as to how this could be done would be appreciated - thanks in advance!

Regards,

--Chris
thumbnail
11年前 に Ahmed bouchriha によって更新されました。

RE: Accessing theme images in WCM templates (回答)

Junior Member 投稿: 55 参加年月日: 12/05/04 最新の投稿
hi Chris Becker :

Try to use :
#set($theme_image_path = $request.get("theme-display").get("path-theme-images"))

for custom themes feel free to visit https://www.themeray.com.
thumbnail
11年前 に Chris Becker によって更新されました。

RE: Accessing theme images in WCM templates

Regular Member 投稿: 112 参加年月日: 10/06/11 最新の投稿
Ahmed bouchriha:
hi Chris Becker :

Try to use :
#set($theme_image_path = $request.get("theme-display").get("path-theme-images"))

for custom themes feel free to visit https://www.themeray.com.



Hi Ahmed;

That worked great - thanks for the info!

Regards,

--Chris
thumbnail
11年前 に Chris Becker によって更新されました。

RE: Accessing theme images in WCM templates

Regular Member 投稿: 112 参加年月日: 10/06/11 最新の投稿
Chris Becker:
Ahmed bouchriha:
hi Chris Becker :

Try to use :
#set($theme_image_path = $request.get("theme-display").get("path-theme-images"))

for custom themes feel free to visit https://www.themeray.com.



Hi Ahmed;

That worked great - thanks for the info!

Regards,

--Chris


Hey Ahmed;

Any chance you would have a similar approach for getting the path to Javascript files?
I tried using the approach above and just request javascript, as follows:
#set($theme_javascript_path = $request.get("theme-display").get("path-theme-javascript"))

However, this did not work. Any ideas?

Regards,

--Chris
thumbnail
11年前 に Ahmed bouchriha によって更新されました。

RE: Accessing theme images in WCM templates (回答)

Junior Member 投稿: 55 参加年月日: 12/05/04 最新の投稿
hello Chris

The theme js path can be retrieved through $themeDisplay.getPathThemeRoot()js on liferay velocity but since $themeDisplay is not available on liferay CMS you cant use it and you have to use the $request.get("theme-display").get("path-theme-images") with some string manipulation like this :

#set($theme_javascript_path = $request.get("theme-display").get("path-theme-images").substring(0, $request.get("theme-display").get("path-theme-images").lastIndexOf("/images")).concat("/js"))


for custom themes feel free to visit https://www.themeray.com.
thumbnail
11年前 に Chris Becker によって更新されました。

RE: Accessing theme images in WCM templates

Regular Member 投稿: 112 参加年月日: 10/06/11 最新の投稿
Ahmed bouchriha:
hello Chris

The theme js path can be retrieved through $themeDisplay.getPathThemeRoot()js on liferay velocity but since $themeDisplay is not available on liferay CMS you cant use it and you have to use the $request.get("theme-display").get("path-theme-images") with some string manipulation like this :

#set($theme_javascript_path = $request.get("theme-display").get("path-theme-images").substring(0, $request.get("theme-display").get("path-theme-images").lastIndexOf("/images")).concat("/js"))


for custom themes feel free to visit https://www.themeray.com.


Wow... almost makes you think that Liferay doesn't want this to happen! emoticon


But it works, Ahmed... thanks again for your help!

Regards,

--Chris
11年前 に Henry K によって更新されました。

RE: Accessing theme images in WCM templates

Junior Member 投稿: 40 参加年月日: 10/01/27 最新の投稿
Hi--

The real, actual request and themeDisplay objects (not the request and themeDisplay maps) are available in liferay cms (at least in LR 6.1.1)

#set ($serviceContext = $portal.getClass().forName("com.liferay.portal.service.ServiceContextThreadLocal").getServiceContext())
#set ($httpServletRequest = $serviceContext.getRequest())
#set ($objThemeDisplay = $httpServletRequest.getAttribute("THEME_DISPLAY"))

See the 3rd to last comment at http://www.liferay.com/web/raymond.auge/blog/-/blogs/custom-velocity-tools-and-liferay-6-0 . This is really good to know!

--Henry
11年前 に Bradley Wood によって更新されました。

RE: Accessing theme images in WCM templates

thumbnail
8年前 に Alessandro Lachina によって更新されました。

RE: Accessing theme images in WCM templates

New Member 投稿: 24 参加年月日: 13/06/12 最新の投稿
I also use it in Freemarker and it work. but in log it give me this error:

Expression request['theme-display'] is undefined on line ......