Question

Using Sitecore 6.6 and Glass 3.0

I've made a MVC layout which uses a View Rendering via Glass. I'm trying to show Highlights.

I've made a View Rendering named GlassHighlights which has the following fields set:

  • Path: /Views/Renderings/KRN/GlassHighlight.cshtml
  • Model: /sitecore/layout/Models/KRN/Highlights

The Model in Sitecore is has the following field set: Model Type: Models.Sitecore.Content.Items.HighLights.Models

The View Rendering is placed on Layout Details on an item named GlassTest (among some other renderings) and placed on placeholder 'body'. The datasource is set to the correct subfolder in sitecore.

This is the model as it is defined in C#:

using System.Collections.Generic;
using Glass.Mapper.Sc.Configuration.Attributes;

namespace Models.Sitecore.Content.Items
{
    /// <summary>
    /// Container folder for the highlights
    /// </summary>
    [SitecoreType(AutoMap = true)]
    public class HighLights
    {
        /// <summary>
        /// Collection of Highlight items
        /// </summary>
        [SitecoreQuery(".//*[@@TemplateId='{EA8BF7CA-157F-4CF4-A2D8-36242304E8FA}']", IsRelative = true)]
        public virtual IEnumerable<Highlight> Items { get; set; }       
    }
}

This is the razorview as it is defined in the project:

@inherits Glass.Mapper.Sc.Web.Mvc.GlassView<Models.Sitecore.Content.Items.HighLights>    

<div class="row topHWContainer">
    @{
        foreach (var highlight in Model.Items)
        {
        <div class="four columns topHW column-first">
            <a href="/eenheiddetails/@highlight.PublicatieID">
                <img src="/Style/Images/bgkArrowRightBlack.png" alt="bgkArrowRightBlack" width="19" height="14">
                <label>@highlight.Titel</label>
                <img src="@highlight.AchterGrondImage.Src" alt="Pimpernel" width="302" height="218" class="topHWimg">
                <div class="topHWinfo">
                    <label>@highlight.Plaats € @highlight.Huur</label>
                </div>
            </a>
        </div>                       
        }
    }
</div>

The code may not be entirely optimal on places as I'm experimenting with things.

Now here's the rub: when I run the website on local it works perfectly fine. Everything renders as it's supposed to render, all data is filled with what is supposed to come out of Sitecore.

When I deploy to staging, the Model doesn't fill and I get a null reference exception when it tries to start the foreach. The Model itself isn't null, but Model.Items is null. Why does this happen? I would like to point out that my local points to the Sitecore Master and the Staging points to Web; but I've deployed every item involved. Did I oversee something?

Why is local working and staging not?

Was it helpful?

Solution

Can you check to see if the assembly is being loaded by Glass.Mapper? If you have your models in a different assembly to the website you need to ensure that they are loaded, see the tutorial http://glass.lu/docs/tutorial/sitecore/tutorial20/tutorial20.html.

OTHER TIPS

I have an issue running at Sitecore itself and after some extensive research they concluded I should upgrade to Sitecore 7.0 (I'm currently at 6.6)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top