Sitecore页面编辑器asp:按钮文本

时间:2014-03-19 13:09:28

标签: sitecore sitecore-dms page-editor

在sitecore页面编辑器模式中,按钮的文字很奇怪;我从sitecore词典中获取此文本。在页面编辑器模式中查看输入字段值的html

<input 
    id='fld_148D7F085F66448D912345030DDBBEBC_2BA3454A9A9C4CDFA9F8107FD484EB6E_en_1_3f45b5b727dc4c93a537e7f688aa6808_1063' 
    class='scFieldValue'  
    name='fld_148D7F085F66448D912345030DDBBEBC_2BA3454A9A9C4CDFA9F8107FD484EB6E_en_1_3f45b5b727dc4c93a537e7f688aa6808_1063' 
    type='hidden' 
    value="Sign Up" 
/>

<span class="scChromeData">
{ "commands": 
    [
        { "click": "chrome:common:edititem({command:\"webedit:open\"})",
          "header": "Edit the related item",
          "icon": "/temp/IconCache/SoftwareV2/16x16/cubes_blue.png",
          "disabledIcon": "/temp/cubes_blue_disabled16x16.png",
          "isDivider": false,
          "tooltip": "Edit this item in the Content Editor.",
          "type": "common"
        },
        { "click": "chrome:rendering:personalize({command:\"webedit:personalize\"})",
          "header": "Personalize","icon":"/temp/IconCache/PeopleV2/16x16/users3_edit.png",
          "disabledIcon": "/temp/users3_edit_disabled16x16.png",
          "isDivider": false,
          "tooltip": "Personalize component.",
          "type": "sticky"
        },
        { "click": "chrome:rendering:editvariations({command:\"webedit:editvariations\"})",
          "header": "Edit variations",
          "icon": "/temp/IconCache/SoftwareV2/16x16/breakpoints.png",
          "disabledIcon": "/temp/breakpoints_disabled16x16.png",
          "isDivider": false,
          "tooltip": "Edit the variations.",
          "type": "sticky"
        }
    ],
    "contextItemUri":"sitecore://master/{148D7F08-5F66-448D-9123-45030DDBBEBC}?lang=en&ver=1",
    "custom":{},
    "displayName":"Phrase",
    "expandedDisplayName":null
}
</span>
<span scFieldType="memo" 
      contenteditable="true" 
      class="scWebEditInput"  
      id="fld_148D7F085F66448D912345030DDBBEBC_2BA3454A9A9C4CDFA9F8107FD484EB6E_en_1_3f45b5b727dc4c93a537e7f688aa6808_1063_edit">
Sign Up
</span>

在正常模式下,输入字段值为Just&#34;注册&#34;。

这只发生在按钮+页面编辑器的组合中。

如果我提供从sitecore

获取字典项的代码,可能会有所帮助
public static string GetDictionaryItem(string expression)
    {
        string val = String.Empty;
        Item currentItem = Context.Database.GetItem(String.Concat("/sitecore/system/dictionary",expression));
        if (currentItem != null)
        {
            val = FieldRenderer.Render(currentItem, "Phrase");
        }
        return val;
    }

有什么建议吗?

1 个答案:

答案 0 :(得分:3)

嗯,它做了它应该做的事情......
您返回FieldRenderer,因此如果您处于页面编辑器模式,它将呈现可编辑字段而不仅仅是文本。

如果您只想要所有渲染模式中的文本,请将您的方法更改为:

public static string GetDictionaryItem(string expression)
{
    Item currentItem = Context.Database.GetItem(String.Concat("/sitecore/system/dictionary",expression));

    if (currentItem != null)
    {
        return currentItem["Phrase"] ?? string.Empty;
    }

    return string.Empty;
}