RenderLink 在体验编辑器模式下隐藏
RenderLink is hidden in experience editor mode
我们正在使用 sitecore 8.1 update 3 和 Glass Mapper 4.2.1.188。
Render Link 在正常模式下工作,但我们在体验模式下看到同样的 link 它隐藏了吗?
剃须刀代码:
<div class="c-home__cta">
@RenderLink(x => x.CallToActionButton, new { @class = "c-btn c-btn--strong c-btn--large" }, isEditable: true)
</div>
体验编辑模式页面来源:
<input id='fld_445CAE7C73764E3BBE7298BB2F1AC2F7_8381EE66B5A54D74B92C9171CD688959_en-GB_7_d1e84aa9693343f28b3b8ac3a0990b8d_35' class='scFieldValue' name='fld_445CAE7C73764E3BBE7298BB2F1AC2F7_8381EE66B5A54D74B92C9171CD688959_en-GB_7_d1e84aa9693343f28b3b8ac3a0990b8d_35' type='hidden' value="<link linktype="internal" text="Discover More" querystring="" target="" id="{8CBC614A-F2B4-4842-81DA-BE4B57992547}" />" /><span class="scChromeData">{"commands":[{"click":"chrome:field:editcontrol({command:\"webedit:editlink\"})","header":"Edit link","icon":"/temp/iconcache/networkv2/16x16/link_edit.png","disabledIcon":"/temp/link_edit_disabled16x16.png","isDivider":false,"tooltip":"Edits the link destination and appearance","type":""},{"click":"chrome:field:editcontrol({command:\"webedit:clearlink\"})","header":"Clear Link","icon":"/temp/iconcache/networkv2/16x16/link_delete.png","disabledIcon":"/temp/link_delete_disabled16x16.png","isDivider":false,"tooltip":"Clears The Link","type":""},{"click":"chrome:common:edititem({command:\"webedit:open\"})","header":"Edit the related item","icon":"/temp/iconcache/office/16x16/cubes.png","disabledIcon":"/temp/cubes_disabled16x16.png","isDivider":false,"tooltip":"Edit the related item in the Content Editor.","type":"common"},{"click":"chrome:rendering:personalize({command:\"webedit:personalize\"})","header":"Personalize","icon":"/temp/iconcache/office/16x16/users_family.png","disabledIcon":"/temp/users_family_disabled16x16.png","isDivider":false,"tooltip":"Create or edit personalization for this component.","type":"sticky"},{"click":"chrome:rendering:editvariations({command:\"webedit:editvariations\"})","header":"Edit variations","icon":"/temp/iconcache/office/16x16/windows.png","disabledIcon":"/temp/windows_disabled16x16.png","isDivider":false,"tooltip":"Edit the variations.","type":"sticky"}],"contextItemUri":"sitecore://master/{445CAE7C-7376-4E3B-BE72-98BB2F1AC2F7}?lang=en-GB&ver=7","custom":{},"displayName":"Call to action button","expandedDisplayName":null}</span><span scFieldType="upm general link" scDefaultText="[No text in field]" contenteditable="true" class="scWebEditInput" id="fld_445CAE7C73764E3BBE7298BB2F1AC2F7_8381EE66B5A54D74B92C9171CD688959_en-GB_7_d1e84aa9693343f28b3b8ac3a0990b8d_35_edit"><link linktype="internal" text="Discover More" querystring="" target="" id="{8CBC614A-F2B4-4842-81DA-BE4B57992547}" /></span>
如有任何建议,我们将不胜感激。
默认情况下,在 link 中向用户显示的文本是外部 link 的描述字段中的值或目标 Sitecore 项目的名称,我想你有这些值为空,您可以通过内容参数覆盖 link 文本,因此如果页面处于编辑模式,只需为内容添加任何文本或空白 space :
@if (Sitecore.Context.PageMode.IsExperienceEditorEditing)
{
RenderLink(x => x.CallToActionButton, new { @class = "c-btn c-btn--strong c-btn--large" }, isEditable: true,contents: "some text")
}
else
{
RenderLink(x => x.CallToActionButton, new { @class = "c-btn c-btn--strong c-btn--large" })
}
我们正在使用 sitecore 8.1 update 3 和 Glass Mapper 4.2.1.188。
Render Link 在正常模式下工作,但我们在体验模式下看到同样的 link 它隐藏了吗?
剃须刀代码:
<div class="c-home__cta">
@RenderLink(x => x.CallToActionButton, new { @class = "c-btn c-btn--strong c-btn--large" }, isEditable: true)
</div>
体验编辑模式页面来源:
<input id='fld_445CAE7C73764E3BBE7298BB2F1AC2F7_8381EE66B5A54D74B92C9171CD688959_en-GB_7_d1e84aa9693343f28b3b8ac3a0990b8d_35' class='scFieldValue' name='fld_445CAE7C73764E3BBE7298BB2F1AC2F7_8381EE66B5A54D74B92C9171CD688959_en-GB_7_d1e84aa9693343f28b3b8ac3a0990b8d_35' type='hidden' value="<link linktype="internal" text="Discover More" querystring="" target="" id="{8CBC614A-F2B4-4842-81DA-BE4B57992547}" />" /><span class="scChromeData">{"commands":[{"click":"chrome:field:editcontrol({command:\"webedit:editlink\"})","header":"Edit link","icon":"/temp/iconcache/networkv2/16x16/link_edit.png","disabledIcon":"/temp/link_edit_disabled16x16.png","isDivider":false,"tooltip":"Edits the link destination and appearance","type":""},{"click":"chrome:field:editcontrol({command:\"webedit:clearlink\"})","header":"Clear Link","icon":"/temp/iconcache/networkv2/16x16/link_delete.png","disabledIcon":"/temp/link_delete_disabled16x16.png","isDivider":false,"tooltip":"Clears The Link","type":""},{"click":"chrome:common:edititem({command:\"webedit:open\"})","header":"Edit the related item","icon":"/temp/iconcache/office/16x16/cubes.png","disabledIcon":"/temp/cubes_disabled16x16.png","isDivider":false,"tooltip":"Edit the related item in the Content Editor.","type":"common"},{"click":"chrome:rendering:personalize({command:\"webedit:personalize\"})","header":"Personalize","icon":"/temp/iconcache/office/16x16/users_family.png","disabledIcon":"/temp/users_family_disabled16x16.png","isDivider":false,"tooltip":"Create or edit personalization for this component.","type":"sticky"},{"click":"chrome:rendering:editvariations({command:\"webedit:editvariations\"})","header":"Edit variations","icon":"/temp/iconcache/office/16x16/windows.png","disabledIcon":"/temp/windows_disabled16x16.png","isDivider":false,"tooltip":"Edit the variations.","type":"sticky"}],"contextItemUri":"sitecore://master/{445CAE7C-7376-4E3B-BE72-98BB2F1AC2F7}?lang=en-GB&ver=7","custom":{},"displayName":"Call to action button","expandedDisplayName":null}</span><span scFieldType="upm general link" scDefaultText="[No text in field]" contenteditable="true" class="scWebEditInput" id="fld_445CAE7C73764E3BBE7298BB2F1AC2F7_8381EE66B5A54D74B92C9171CD688959_en-GB_7_d1e84aa9693343f28b3b8ac3a0990b8d_35_edit"><link linktype="internal" text="Discover More" querystring="" target="" id="{8CBC614A-F2B4-4842-81DA-BE4B57992547}" /></span>
如有任何建议,我们将不胜感激。
默认情况下,在 link 中向用户显示的文本是外部 link 的描述字段中的值或目标 Sitecore 项目的名称,我想你有这些值为空,您可以通过内容参数覆盖 link 文本,因此如果页面处于编辑模式,只需为内容添加任何文本或空白 space :
@if (Sitecore.Context.PageMode.IsExperienceEditorEditing)
{
RenderLink(x => x.CallToActionButton, new { @class = "c-btn c-btn--strong c-btn--large" }, isEditable: true,contents: "some text")
}
else
{
RenderLink(x => x.CallToActionButton, new { @class = "c-btn c-btn--strong c-btn--large" })
}