抑制 Widget.Wrapper 而不抑制 Widget.ControlWrapper [英] Suppressing Widget.Wrapper without suppressing Widget.ControlWrapper

查看:41
本文介绍了抑制 Widget.Wrapper 而不抑制 Widget.ControlWrapper的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小部件的替代视图.在该视图中,我使用如下代码抑制包装器:

I have an alternate view for a widget. In that view I'm suppressing the wrapper using code like this:

Model.Metadata.Wrappers.Clear();

这行得通,但我只想抑制 Widget.Wrapper.现在,它还抑制了 Widget.ControlWrapper,这会在我启用 Widget Control Wrapper 模块时阻止显示编辑按钮.

This works, but I'd like to only suppress the Widget.Wrapper. Right now it is also suppressing the Widget.ControlWrapper which prevents the edit buttons from displaying when I have the Widget Control Wrapper module enabled.

有什么办法可以在保留 Widget.ControlWrapper 的同时只清除 Widget.Wrapper 吗?

Is there any way to clear only the Widget.Wrapper while keeping the Widget.ControlWrapper?

推荐答案

如果有人遇到类似问题,我可以在我的主题中的 Widget-Sidebar.cshtml 文件中抑制 Widget.Wrapper:

In case anyone comes across this for a similar problem, I was able to suppress the Widget.Wrapper thusly in a Widget-Sidebar.cshtml file in my theme:

@using Orchard.DisplayManagement.Descriptors;
@using Orchard.Environment.Extensions;
@{
    Model.Metadata.Wrappers.Remove("Widget_Wrapper");
    Model.Metadata.Wrappers.Add("Widget_SideBarWrapper");
    Model.Metadata.Wrappers.Add("Widget_ControlWrapper");
}
@Display(Model.Content)

我开始使用形状跟踪工具为我在侧边栏"列中的小部件创建替代品(基本上是一个 <div id="sidebar"> 我在我的布局为 @Zone(Model.Sidebar)).

I started out by using the Shape Tracing tool to create an alternate for widgets I had in a "sidebar" column (basically a <div id="sidebar"> I have in my layout as @Zone(Model.Sidebar)).

我将上面的代码放在我使用形状跟踪创建的 Widget-Sidebar.cshtml 替代中.

I placed the code above in the Widget-Sidebar.cshtml alternate that I created using Shape Tracing.

Model.Metadata.Wrappers.Clear(); as used by the OP completely removes everything, to the point where in Shape Tracing it won't even show up as a widget. Adding my own alternate (Widget.SideBarWrapper.cshtml, which is added as "Widget_SideBarWrapper" above) would not fix this. I felt that was wrong even though the content displayed.

Model.Metadata.Wrappers.Remove("Widget_Wrapper");

似乎是正确的方法(即形状跟踪仍然显示一个小部件),但它似乎删除了所有其他包装器,因此您必须添加新包装器以及 Widget.ControlWrapper.cshtml(写为"Widget_ControlWrapper"在上面的代码中).

seemed the right way to go (i.e., Shape Tracing still showed a Widget), but it appears to REMOVE all the other wrappers, so you then have to add your new wrapper along with Widget.ControlWrapper.cshtml (written as "Widget_ControlWrapper" in code above).

HTH.

这篇关于抑制 Widget.Wrapper 而不抑制 Widget.ControlWrapper的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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