Umbraco is now the latest CMS supported by Glass.Mapper.

We have been working extending support for Umbraco 6 in Glass.Mapper. There is an early release available to try out the integration with Umbraco.

The features included in this release are:

  • Reading Data
  • Writing Data
  • Auto Mapping
  • On Demand Mapping
  • Fluent Configuration
  • Attribute Configuration
  • Constructor Injection
  • Castle Windsor DI

To get started with auto-mapping, it is easy as this.

    [UmbracoType(AutoMap =  true)]
    public class HomePage
    {
        public virtual string Title { get; set; }
        public virtual string MainBody { get; set; }
        public virtual int NewsArticlesToShow { get; set; }
        public virtual string HeroColour { get; set; }
        [UmbracoProperty("NewsLanding")]
        public virtual NewsLanding LandingPage { get; set; }
    }

To map your razor layout to your model, inherit from GlassTemplatePage.

@inherits Glass.Mapper.Umb.Web.Ui.GlassTemplatePage<Glass.Mapper.Sites.Umb.Models.Landing.HomePage>
@{
    Layout = "BaseLayout.cshtml";
}
<div class="hero-unit">
    <h1 style="color: #@Model.HeroColour">@Model.Title</h1>
    @Html.Raw(Model.MainBody)
</div>

<div class="span6">
    <h3>Featured News</h3>
    <ul class="thumbnails">
        @foreach (var news in Model.NewsLanding.Articles.Take(Model.NewsArticlesToShow))
        {
        <li>
            <div class="thumbnail">
                @if (news.FeaturedImage != null)
                {
                    <img src="@news.FeaturedImage.Src"  />
                }
                <h4>
                    <a href="@Umbraco.NiceUrl(news.Id)">
                        @news.Title
                    </a>
                </h4>
                <p>@news.Abstract</p>
            </div>
        </li>
        }
    </ul>
</div>

There is still plenty of work to do and the main feature still to come is code first document type generation. The project is up on GitHub so feel welcome to raise issues or contribute to the framework.

Tutorials coming soon!

comments powered by Disqus