gpt4 book ai didi

Sitecore 8 MVC : How to make the field editable in Page Editor

转载 作者:行者123 更新时间:2023-12-03 06:22:43 25 4
gpt4 key购买 nike

我正在尝试使我的 Sitecore 网站与页面编辑器兼容,即所有字段文本、富文本编辑器等都应该能够在页面编辑器中更新。

到目前为止,我已经修改了 TDS T4 模板,它为每个字段返回一个 HTMLString,如下所示:

public HtmlString HeroImageField(bool isEditable = true, string parameters = "")
{
string renderParameter = GenerateRenderParameter(isEditable, parameters);

return new HtmlString(Sitecore.Web.UI.WebControls.FieldRenderer.Render(
Sitecore.Context.Database.GetItem(this.EntityId.ToString()), "Hero Image", renderParameter ));
}

因此,在 View 中我只需调用 Model.HeroImage()

有没有更好的方法来实现上述目标?也许 Glass Mapper 对此提供了开箱即用的支持(我不知道)。

最佳答案

Sitecore 附带 MVC 帮助程序,您可以使用它们使字段可编辑:

@Html.Sitecore().Field("My Field Name") //Context item by default
@Html.Sitecore().Field("My Field Name", Model.PageItem) //Explicit page item
@Html.Sitecore().Field("My Field Name", Model.Item) //Datasource item (may be context item)

我的建议也是使用 Controller 加载不同的 View 进行编辑。创作领域通常需要不同的视觉效果。轮播/选项卡应该展平,验证消息需要公开,等等。

查看更多信息: http://sitecore-community.github.io/docs/sitecore-mvc/rendering-content/

关于Sitecore 8 MVC : How to make the field editable in Page Editor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33145431/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com