简体   繁体   English

在Liferay的显示模板中访问并呈现文档的图像

[英]Get access and render document's image in Liferay's Display Template

I'm using Liferay 6.2 CE and I would like create a very simple Application Display Template for Asset Publisher which would display only one image without any additional metadata. 我正在使用Liferay 6.2 CE,我想为Asset Publisher创建一个非常简单的Application Display Template ,它只显示一个没有任何附加元数据的图像。 The purpose of this is to allow page admin to just drag and drop an existing document (which contains only an image) that would eg fill entire column on a page. 这样做的目的是允许页面管理员只拖放现有文档(其中只包含一个图像),例如填充页面上的整个列。

My problem is that I don't know how to access this image. 我的问题是我不知道如何访问此图像。

I would like to do something like this: 我想做这样的事情:

<#assign img=renderRequest.getImageUrl()>
<img url="{$img}" />

I've used freemarker to list all attributes 我用freemarker列出了所有属性

<#assign x=renderRequest.getAttributeNames()>

<#list x as item>
    <br/>
    ${item}
</#list>

which gave me the result: 这给了我结果:

LAST_PATH
FRIENDLY_URL
liferay-ui:success:message
javax.servlet.forward.context_path
RENDER_PORTLET_COLUMN_ID
PORTLET_AJAX_RENDER
com.liferay.portal.servlet.filters.gzip.GZipFilterSKIP_FILTER
THEME
javax.servlet.forward.servlet_path
javax.portlet.config
RENDER_PORTLET_COLUMN_POS
liferay-ui:error:rowBreak
org.apache.struts.action.MODULE
javax.portlet.response
COMPANY
javax.servlet.forward.query_string
bodyContent
javax.servlet.forward.path_info
com.liferay.portal.servlet.filters.i18n.I18nFilterSKIP_FILTER
User-Agent
view.jsp-results
INVOKER_FILTER_URI
liferay-ui:error:translateMessage
com.liferay.portal.kernel.util.CookieKeys
javax.servlet.include.context_path
dynamicAttributes
javax.portlet.lifecycle_phase
VIRTUAL_HOST_LAYOUT_SET
liferay-ui:success:key
scopedAttributes
javax.servlet.include.servlet_path
javax.servlet.forward.request_uri
COLOR_SCHEME
PORTLET_STRUTS_ACTION
liferay-ui:error:message
liferay-ui:success:translateMessage
LIFERAY_SHARED_SEARCH_CONTAINER_REFERENCE
LIFERAY_SHARED_THEME_DISPLAY
WINDOW_STATE
CURRENT_COMPLETE_URL
SERVLET_CONTEXT_INCLUDE_FILTER_STRICT
javax.servlet.include.request_uri
com.liferay.portal.servlet.filters.strip.StripFilterSKIP_FILTER
ACCEPT
LAYOUT
RENDER_PORTLET
USER_ID
org.apache.struts.taglib.tiles.CompContext
COMPANY_ID
USER
LAYOUTS
RENDER_PORTLET_COLUMN_COUNT
PORTLET_PARALLEL_RENDER
liferay-ui:error:key
PORTLET_ID
com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterSECURE_RESPONSE
javax.portlet.request
CURRENT_URL
CTX
org.apache.struts.action.mapping.instance 

But I still can't figure out which attribute is responsible for retrieving images... Or is there any other way to achieve this? 但我仍然无法弄清楚哪个属性负责检索图像...或者还有其他方法可以实现这一目标吗?

My opinion for this approach you need new Web Content Structure and Web Content Template (and not Application Display Template). 我对这种方法的看法是你需要新的Web内容结构和Web内容模板(而不是应用程序显示模板)。

Create new Web Content Structure with only one image field: 仅使用一个图像字段创建新的Web内容结构:

在此输入图像描述

在此输入图像描述

Create new Web Content Template: 创建新的Web内容模板:

在此输入图像描述

ans associate structure and template: ans关联结构和模板:

在此输入图像描述

Ready: 准备:

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM