0

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?

tereško
  • 58,060
  • 25
  • 98
  • 150
Joost Bollen
  • 90
  • 2
  • 10

2 Answers2

1

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.

Michael Edwards
  • 6,308
  • 6
  • 44
  • 75
  • My GlassMapperScCustom looks like this: `code` public static IConfigurationLoader[] GlassLoaders(){ var attributes = new SitecoreAttributeConfigurationLoader("Website", "Models", "Managers"); return new IConfigurationLoader[]{attributes}; }`code` So yes, I think the correct assemblies should be loaded. As I pointed out: it works on local. If the assemblies didn't load, it wouldn't work on local either, would it? – Joost Bollen Sep 24 '13 at 11:26
  • I deleted the loading of Models and now I get the same error on local. So it could be the assembly doesn't load well on Staging. But why? – Joost Bollen Sep 24 '13 at 11:47
  • That is very odd, can you check which versions of the .NET framework they are compiling to and what version is available on the server? – Michael Edwards Sep 24 '13 at 15:12
  • Using .Net v4.0.30319 – Joost Bollen Sep 25 '13 at 08:15
  • 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) – Joost Bollen Sep 27 '13 at 07:37
0

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)

Joost Bollen
  • 90
  • 2
  • 10
  • So this wasn't an issue caused by Glass.Mapper? I just want to be sure that I don't need to fix anything. – Michael Edwards Sep 27 '13 at 14:42
  • Well, Sitecore Marketplace says Glass only supports CMS 6.2, 6.3, 6.3.1, 6.4, 6.4.1 and 6.5. After searching I've found most people using it with 7.0. I'm at 6.6, getting no support from Sitecore and I can't just upgrade to 7.0. So I have no idea if an upgrade would in fact solve the problem. It still doesn't explain why it works on local and not on Staging. The only sollution I'm currently using is not using View Renderings, but only Controller Renderings. – Joost Bollen Sep 30 '13 at 08:41