Fórum
Accessing theme images in WCM templates
Chris Becker, modificado 11 Anos atrás.
Accessing theme images in WCM templates
Regular Member Postagens: 112 Data de Entrada: 11/06/10 Postagens Recentes
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
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
Ahmed bouchriha, modificado 11 Anos atrás.
RE: Accessing theme images in WCM templates (Resposta)
Junior Member Postagens: 55 Data de Entrada: 04/05/12 Postagens Recentes
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.
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.
Chris Becker, modificado 11 Anos atrás.
RE: Accessing theme images in WCM templates
Regular Member Postagens: 112 Data de Entrada: 11/06/10 Postagens RecentesAhmed 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
Chris Becker, modificado 11 Anos atrás.
RE: Accessing theme images in WCM templates
Regular Member Postagens: 112 Data de Entrada: 11/06/10 Postagens RecentesChris 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
Ahmed bouchriha, modificado 11 Anos atrás.
RE: Accessing theme images in WCM templates (Resposta)
Junior Member Postagens: 55 Data de Entrada: 04/05/12 Postagens Recentes
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 :
for custom themes feel free to visit https://www.themeray.com.
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.
Chris Becker, modificado 11 Anos atrás.
RE: Accessing theme images in WCM templates
Regular Member Postagens: 112 Data de Entrada: 11/06/10 Postagens RecentesAhmed 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!
But it works, Ahmed... thanks again for your help!
Regards,
--Chris
Henry K, modificado 11 Anos atrás.
RE: Accessing theme images in WCM templates
Junior Member Postagens: 40 Data de Entrada: 27/01/10 Postagens Recentes
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
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
Bradley Wood, modificado 11 Anos atrás.
RE: Accessing theme images in WCM templates
Alessandro Lachina, modificado 8 Anos atrás.
RE: Accessing theme images in WCM templates
New Member Postagens: 24 Data de Entrada: 12/06/13 Postagens Recentes
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 ......
Expression request['theme-display'] is undefined on line ......