果园替代不同区域 [英] Orchard alternates for different zones

查看:94
本文介绍了果园替代不同区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Projection Widget,它在AsideSecond区域中显示内容类型.我使用Placement.info禁止显示大多数元数据.

I have a Projection Widget that displays a content type in the AsideSecond zone. I used Placement.info to suppress most of the metadata.

在该内容类型的主页上,我希望所有元数据都显示在内容"区域中.

On the main page for that content type I want all the metadata displayed in the Content zone.

我似乎无法弄清楚如何根据渲染形状的位置指定备用模板.它们都具有摘要"的显示类型.我尝试的所有操作都将抑制/替代模板应用于这两者.

I cannot seem to work out how to specify an alternate template based on where the Shape is being rendered. They both have a display type of Summary. Everything I attempt applies the suppression/alternate template to both.

因为这些是将在使用论坛时添加的主题,所以我不能将ID替代作为可行的选择.

As these are threads which will be added as the forum is used I cannot use the ID alternate as a viable option.

我相关的位置:

<Match ContentType="Thread">
  <Match DisplayType="Summary">
    <Place Parts_Common_Metadata_Summary="-"/>
    <Place Parts_Threads_Thread_ThreadReplyCount="-"/>
    <Place Forum_Metadata_First="-"/>
  </Match>
</Match>

我尝试将Place元素嵌套在<Match ContentType="Widget">元素下,但无济于事.

I have tried nesting the Place elements under a <Match ContentType="Widget"> element, but to no avail.

这有可能吗?

更新:我在投影小部件中使用的查询上创建了一个Shape布局.我在主题视图"文件夹中创建了自己的列表形状,并且可以进行一些铸造来访问所需的相关属性.因此,我可以解决我的问题.

Update: I created a Shape layout on the query used in the projection widget. I created my own list shape in the theme Views folder and can access the relevant properties I need with a bit of casting. So, I can work around my issue.

我仍然想知道是否可以根据区域设置替代项,或者是否可以在小部件中呈现内容.我对此已经看到了几个关于SO的问题,这些问题几乎没有答案(例如,

I would still like to know if it is possible to set an alternate based on the zone or whether the content is rendered in a widget. I have seen several, mostly unanswered, questions on SO regarding this (e.g. How to suppress parts in Orchard based on zone)

推荐答案

果园讨论论坛.

面临的挑战是,您不容易知道要在其中渲染零件形状的区域.如果要向Widget形状添加替代,那么这很容易,因为Widget知道它们属于哪个区域.

The challenge is that you can't easily know what zone your part shapes are being rendered in. If you wanted to add alternates to the Widget shape then that would be easy, since widgets know to which zone they belong.

所以简短的答案是:不,不是开箱即用.但是,您可以 实现IShapeTableProvider并描述Widget形状.这 形状将包含对ContentItem的引用(该引用具有一个 附带的WidgetPart,通过它可以访问区域名称 和子形状(包括类似 Parts_Title_Summary),因此您可以遍历此形状树并添加 根据区域名称交替显示.

So the short answer is: no, not out of box. However, you could implement an IShapeTableProvider and describe the Widget shape. This shape will contain a reference to the ContentItem (which will have a WidgetPart attached through which you can access the zone name it belongs to) and child shapes (including shapes like Parts_Title_Summary), so you could walk this shape tree and add alternates to each based on the zone name.

不好看,但是可以用.

因此,这不是一个简单的备用命名或放置解决方案.我认为最好的行动计划是,如果您尝试在区域之间使用相同的ContentType和DisplayType,则为查询编写自己的布局.希望这对某人有帮助.

So it is not a simple alternate naming or placement solution. I feel the best plan of action is to write ones own layout for a query if you are attempting to use the same ContentType and DisplayType across zones. Hope this helps someone.

这篇关于果园替代不同区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆