如何覆盖Orchard CMS中导航区域的渲染?

时间:2022-01-07 13:19:51

I'm new to Orchard, so I probably have no idea what I'm doing.

我是Orchard的新手,所以我可能不知道我在做什么。

I've figured out how to override different shapes but putting a cshtml file in the View folder with the same name as the shape.

我已经想出如何覆盖不同的形状,但将一个cshtml文件放在View文件夹中,其名称与形状相同。

Also, I found the Menu and MenuItem shape cshtml files under the Core Orchard files.

另外,我在Core Orchard文件下找到了Menu和MenuItem形状的cshtml文件。

However, I don't see a shape named Navigation and I don't really understand how Zones work.

但是,我没有看到名为Navigation的形状,我不太了解Zones的工作原理。

I searched the code and couldn't figure out exactly how the Navigation is rendered, though I did find some of the code.

我搜索了代码并且无法确切地知道导航是如何渲染的,尽管我确实找到了一些代码。

The reason that I want to override the Navigation rendering is that it renders a DIV and a NAV tag around the UL. I would prefer to just render the NAV and UL.

我想要覆盖导航渲染的原因是它在UL周围呈现DIV和NAV标记。我更愿意只渲染资产净值和UL。

2 个解决方案

#1


11  

Zones are also shapes, but they are declared in code (Core/Shapes/CoreShapes.cs), not in .cshtml files like most of shapes. Also, there is no shape called Navigation, as zones are created dynamically at runtime - names of those are provided by the theme used.

区域也是形状,但它们在代码(Core / Shapes / CoreShapes.cs)中声明,而不是像大多数形状一样在.cshtml文件中声明。此外,没有称为导航的形状,因为区域是在运行时动态创建的 - 这些名称由所使用的主题提供。

Zones have default alternates in the form Zone__[ZoneName]. It means you just need to put Zone-Navigation.cshtml file in /Views folder in your theme folder to override Navigation zone rendering.

区域具有区域__ [ZoneName]形式的默认替代项。这意味着您只需将Zone-Navigation.cshtml文件放在主题文件夹的/ Views文件夹中即可覆盖导航区域渲染。

#2


1  

If you are using the latest 1.1.3 release you can use the new shape tracing tool from the designer tools module. It provides a list of URL alternates to name your template in order to override the default rendering.

如果您使用的是最新的1.1.3版本,则可以使用设计器工具模块中的新形状跟踪工具。它提供了一个URL替换列表,用于命名模板以覆盖默认呈现。

#1


11  

Zones are also shapes, but they are declared in code (Core/Shapes/CoreShapes.cs), not in .cshtml files like most of shapes. Also, there is no shape called Navigation, as zones are created dynamically at runtime - names of those are provided by the theme used.

区域也是形状,但它们在代码(Core / Shapes / CoreShapes.cs)中声明,而不是像大多数形状一样在.cshtml文件中声明。此外,没有称为导航的形状,因为区域是在运行时动态创建的 - 这些名称由所使用的主题提供。

Zones have default alternates in the form Zone__[ZoneName]. It means you just need to put Zone-Navigation.cshtml file in /Views folder in your theme folder to override Navigation zone rendering.

区域具有区域__ [ZoneName]形式的默认替代项。这意味着您只需将Zone-Navigation.cshtml文件放在主题文件夹的/ Views文件夹中即可覆盖导航区域渲染。

#2


1  

If you are using the latest 1.1.3 release you can use the new shape tracing tool from the designer tools module. It provides a list of URL alternates to name your template in order to override the default rendering.

如果您使用的是最新的1.1.3版本,则可以使用设计器工具模块中的新形状跟踪工具。它提供了一个URL替换列表,用于命名模板以覆盖默认呈现。