Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to implement Sitecore Template inheritance with Glass Mapper
    primarykey
    data
    text
    <p>I've been trying to achieve the following with glass mapper but can't get it to work.</p> <p>I have a Home Page template which doesn't have any fields itself but inherits the following two templates:</p> <p><code>Navigation Template</code></p> <p><code>Fields: Navigation Title</code></p> <p><code>Meta Information Template</code></p> <p><code>Fields: Page Title, Meta Description</code></p> <p>I've created the corresponding interfaces / classes as follows:</p> <pre class="lang-cs prettyprint-override"><code>[SitecoreType(TemplateId = "{5BAB563C-12AD-4398-8C4A-BF623F7DBCDC}", AutoMap = true)] public interface INavigation { [SitecoreField(FieldName = "Navigation Title")] string NavigationTitle { get; set; } } [SitecoreType(TemplateId = "{95539498-31A5-4CB5-8DD6-C422D505C482}", AutoMap = true)] public interface IMetaInformation { [SitecoreField] string PageTitle { get; set; } [SitecoreField] string MetaDescription { get; set; } } [SitecoreType(TemplateId = "{F08693E5-8660-4B13-BBD6-7B9DC6091750}", AutoMap = true)] public class HomePage : INavigation, IMetaInformation { public virtual string NavigationTitle { get; set; } public virtual string PageTitle { get; set; } public virtual string MetaDescription { get; set; } } </code></pre> <p>When I then try accessing my page all attributes are always null:</p> <pre class="lang-cs prettyprint-override"><code>var context = new SitecoreContext(); var page = context.GetCurrentItem&lt;HomePage&gt;(); </code></pre> <p>I've tried several different approaches to this but nothing works. Also what was described in different tutorials didn't work. The only thing that works is when I add the fields directly on the Home Page template, but I don't want that since I have more than one page type and I therefore want to inherit the fields. </p> <p>Does anyone have any idea what I'm missing here?! I'm using Sitecore 7 with .NET 4.5 by the way if that makes a difference.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload