5earch
5earch

Reputation: 289

How to render field in PageEditor when using Template inheritance with Sitecore Glass Mapper

I have the following setup in my solution, described in an earlier post:

How to implement Sitecore Template inheritance with Glass Mapper

I'm able to display the content of inherited fields now. However when I try to edit them in the page editor the EditFrame is not rendered, nothing gets rendered actually. Not sure what I'm still missing. Here's my controller and view:

Controller:

public class NavigationController : Controller
{
    // GET: /Navigation/

    public ActionResult Index()
    {
        var context = new SitecoreContext();
        var page = context.GetCurrentItem<HomePage>();

        return View("/Views/Navigation.cshtml", page);
    }
}

View:

@inherits Glass.Mapper.Sc.Web.Mvc.GlassView<Sitecore.Training7.Internet.Core.Models.HomePage>
@if (Model != null)
{
     <h3 class="text-muted">Field: @Editable(x => x.NavigationTitle)</h3>
}

When I hit the preview button the value is displayed, I don't see the value in the PageEditor though. What am I still missing here? Any ideas?

Upvotes: 0

Views: 721

Answers (2)

aceanindita
aceanindita

Reputation: 494

I see your other post now, please add the Id:

    [SitecoreId]
    Guid Id{ get; }

In page editor mode, sitecore would require the mapped Id to know which item the value belongs to. So you will need to add this to your model too. If by any chance you are using TDS or something similar - you'll see that the property is added by default in the base class for all model classes by default.

Upvotes: 0

Ben Golden
Ben Golden

Reputation: 1580

This is just a guess based on the HomePage model that you included in your other post, but I think you need to add an ID property to your model. See http://glass.lu/docs/tutorial/sitecore/tutorial05/tutorial05.html

Upvotes: 1

Related Questions