Sitecore的 - 功能区隐藏按钮 [英] Sitecore - Hide Button in Ribbon

查看:237
本文介绍了Sitecore的 - 功能区隐藏按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个上下文功能区为特定内容项目。我有两个按钮,将促进或降级的项目,以某一类(只能有一个在一节)。

I created a Contextual Ribbon for a specific content item. I have two buttons that will "promote" or "demote" the item to a certain category (there can only be one in the section).

是否有可能隐藏的基础上在某种背后code的内容状态的按钮中的一个?我知道如何链接至Click事件,但我想知道是否有某种形式的自定义功能区访问负载事件。

Is it possible to hide one of the buttons based on the contents state in some sort of code behind? I understand how to link up to the Click event, but I was wondering if there was some sort of load event for the custom ribbon to access.

推荐答案

看来我可以用一个继承自命令覆盖同一类QueryState 方法。这就是所谓的加载按钮的时候,我可以做一个检查那里返回 CommandState.Hidden 如果不应该显示的按钮

Seems I can use the same class that inherits from Command to override the QueryState method. This is called when the buttons are loaded, and I can do a check there and return a CommandState.Hidden if the button shouldn't be shown

public override CommandState QueryState(CommandContext context)
{
    var item = context.Items[0];

    return item.Fields["Spotlight"].Value == "" ? CommandState.Hidden : base.QueryState(context);
}

这篇关于Sitecore的 - 功能区隐藏按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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