6

如何向我的 Tridion 2011 GUI Extension 上下文菜单项添加图标?

是在主题还是 GUI 扩展配置中?

尺寸是16px吗?

4

3 回答 3

11

是的,图标是 16 x 16。

我一直使用 CSS 来完成它,我希望这个解释是有道理的:

1)在你的editor.config中,你指定你需要的css文件和其他资源

<cfg:groups>
  <cfg:group name="PowerTools.Resources.Base" merge="always">
    <cfg:fileset>
        <cfg:file type="style">/PowerTools/Client/Shared/Theme/styles.css</cfg:file>

2)配置上下文菜单时,在ContextMenuItem中有ID属性(下图为PT_PagePublisher)

<ext:contextmenus>
  <ext:add>
    <ext:extension name="PowerToolsContextMenu" assignid="PowerToolsContextMenu" insertbefore="cm_refresh">
      <ext:menudeclaration externaldefinition="">
        <cmenu:ContextMenuItem id="PowerToolsMenuGroup" name="Power Tools">
          <cmenu:ContextMenuItem id="PT_PagePublisher" name="Page Publisher" command="PT_PagePublisher"/>

3)在您的 CSS 文件中,您将拥有如下内容:

.PT_PagePublisher .image {background-image:url({ThemePath}/Icons/pagepublisher_16.png);}

查看 CSS 类 (PT_PagePublisher) 的名称如何映射到 ContextMenuItem 节点中的 ID。

I hope this helps!

于 2012-02-27T15:01:58.717 回答
2

您使用主题 CSS。我的开发图像中的扩展在 CSS 中有以下内容:

.tridion .contextmenu #TweetThis .image
{
    background-image:url({ThemePath}/images/icons/twitter-icon16x16.png);
}

TweetThis 是我的上下文菜单项 ID,在扩展配置中定义。

于 2012-02-27T14:49:19.480 回答
1

In case you want to reuse an image of the current CME (Content Manager Explorer) you can use the following:

#PT_PagePublisher.item .image
{
    background-image: url({ThemePath['CME']}/Sprites/cme_5_v6.1.0.55920.0_.png);
    background-position: 0px -480px;
    height: 16px;
    width: 16px;
}

This example shows the publish icon from a 2011 SP1 install. So you can use {ThemePath['EditorName']} to access the theme path of any editor which is configured actually.

Also in some cases I have found that my images would not load on either the ribbon toolbar or the context menu, that appeared to be an authorization issue on the editors virtual directory in IIS.

I solved it by adding a Web.config file to my Theme (root) directory which will allow access to all users for the theme files (css and images).

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.web>
        <!-- allow all users access to theme files -->
        <authorization>
            <allow users="?" />
        </authorization>
    </system.web>
</configuration>
于 2012-03-16T11:35:10.903 回答