Kentico 9 改造 page/file URL
Kentico 9 transformation page/file URL
在我的自定义页面类型中,您可以select上传文件。很好,但是在我的 ascx 转换中,我很难获得 URL。该字段是 'Process'.
这是我目前拥有的。
<%# IfEmpty(Eval("Process"),"N/A","<a href=" + Eval("Process") +" target='blank' class='icon download'>Download</a>")%>
呈现后,html 是这样的:
<a href="214b6876-cb39-4a58-813f-19dcb7c788e4" target="blank" class="icon download">Download</a>
我遗漏了一些东西。
查看 transformation methods reference
您可以使用 <%#GetImage(Eval("Process"))%>。这将 return 一个图片标签。如果您想使用这些参数,还有一些其他参数可以调整大小。
请参阅您的 Transnformation 编辑器上的“Transformation reference”link,它包含您可以使用的所有可用转换方法。
其中显示:
这将生成一个实际的图像标签。但是,如果您想要 link,通常是
/getattachment/<%# Eval("TheImage")%>/ImageFileNameCanBeAnythingThough.jpg
示例:
/getattachment/1936c69d-a28c-428a-90a7-09154918da0f/Christmas.jpg
您可以使用以下两种方法之一。不过两者都有缺点。
<a href="<%# GetFileUrl("Process", "Something") %>"Link here<a/>
这将
缺点是如果 "Process" 字段中没有值,它将 return 无效 URL。所以我倾向于使用一些更好的东西(但不是很多)
<a href="/getattachment/<%# ValidationHelper.GetGuid(Eval("Process"), Guid.Empty) %>/<%# ValidationHelper.GetString(Eval("NodeAlias"), "download") %>">Item to download</a>
这将创建一个带有一些无效属性的有效 URL。这意味着如果 Process 字段中没有值,它将 return 00000000-0000-0000-0000-000000000000
。如果 NodeAlias 字段为空,它将 return "download"。同样,不是 100% fool-proof 但在大多数情况下效果很好。
更新
看看这个 link:
https://devnet.kentico.com/articles/options-for-file-fields-in-structured-data
我认为您需要的文章在 "CMS.File page type" 部分:
<a href="<%#GetDocumentUrl("FileField ", "kenticopicture")%>">This is the link to the picture</a>
在我的自定义页面类型中,您可以select上传文件。很好,但是在我的 ascx 转换中,我很难获得 URL。该字段是 'Process'.
这是我目前拥有的。
<%# IfEmpty(Eval("Process"),"N/A","<a href=" + Eval("Process") +" target='blank' class='icon download'>Download</a>")%>
呈现后,html 是这样的:
<a href="214b6876-cb39-4a58-813f-19dcb7c788e4" target="blank" class="icon download">Download</a>
我遗漏了一些东西。
查看 transformation methods reference
您可以使用 <%#GetImage(Eval("Process"))%>。这将 return 一个图片标签。如果您想使用这些参数,还有一些其他参数可以调整大小。
请参阅您的 Transnformation 编辑器上的“Transformation reference”link,它包含您可以使用的所有可用转换方法。
其中显示:
这将生成一个实际的图像标签。但是,如果您想要 link,通常是
/getattachment/<%# Eval("TheImage")%>/ImageFileNameCanBeAnythingThough.jpg
示例: /getattachment/1936c69d-a28c-428a-90a7-09154918da0f/Christmas.jpg
您可以使用以下两种方法之一。不过两者都有缺点。
<a href="<%# GetFileUrl("Process", "Something") %>"Link here<a/>
这将
缺点是如果 "Process" 字段中没有值,它将 return 无效 URL。所以我倾向于使用一些更好的东西(但不是很多)
<a href="/getattachment/<%# ValidationHelper.GetGuid(Eval("Process"), Guid.Empty) %>/<%# ValidationHelper.GetString(Eval("NodeAlias"), "download") %>">Item to download</a>
这将创建一个带有一些无效属性的有效 URL。这意味着如果 Process 字段中没有值,它将 return 00000000-0000-0000-0000-000000000000
。如果 NodeAlias 字段为空,它将 return "download"。同样,不是 100% fool-proof 但在大多数情况下效果很好。
更新
看看这个 link:
https://devnet.kentico.com/articles/options-for-file-fields-in-structured-data
我认为您需要的文章在 "CMS.File page type" 部分:
<a href="<%#GetDocumentUrl("FileField ", "kenticopicture")%>">This is the link to the picture</a>