Skip to content

Instantly share code, notes, and snippets.

@wiedikerli
Last active January 18, 2017 21:35
Show Gist options
  • Save wiedikerli/13d8b6a2e420884445dd3fe26fa0c39a to your computer and use it in GitHub Desktop.
Save wiedikerli/13d8b6a2e420884445dd3fe26fa0c39a to your computer and use it in GitHub Desktop.
@model GridControl
@{
string view = Model.Editor.Render != null ? Model.Editor.Render.ToString() : Model.Editor.View.ToString();
view = view.ToLower().Replace(".html", ".cshtml");
if (!view.Contains("/"))
{
view = "grid/editors/" + view;
}
}
@Html.Partial(view, Model.JObject, new ViewDataDictionary(this.ViewData))
@inherits ModulesViewPage<CallToActionCall>
@if (Model != null)
{
using (Html.OptenModule(Model, "call-to-action -call-1"))
{
<div class="row flex-row">
<div class="col-md-10 col-sm-8">
@if (Model.Title.IsNullOrWhiteSpace() == false)
{
<h2 class="call-to-action-title text-uppercase">@Html.Raw(Model.Title)</h2>
}
@if (Model.Subtitle.IsNullOrWhiteSpace() == false)
{
<h2 class="call-to-action-subtitle text-uppercase">@Html.Raw(Model.Subtitle)</h2>
}
</div>
<div class="col-md-2 col-sm-4">
@if (Model.Links != null && Model.Links.Any())
{
<ul class="call-to-action-button-list">
@foreach (var link in Model.Links)
{
<li>
@link.AsLink(htmlAttributes: new { @class = "btn btn-primary btn-block call-to-action-button text-uppercase", target = link.Target })
</li>
}
</ul>
}
</div>
</div>
}
}
@inherits UmbracoViewPage<GridDataModel>
@if (Model != null && Model.Sections != null)
{
foreach (var section in Model.Sections)
{
foreach (var row in section.Rows)
{
foreach (var area in row.Areas)
{
foreach (var control in area.Controls)
{
if (control != null && control.Editor != null && control.Editor.View != null)
{
@Html.Partial("grid/editors/base", control)
}
}
}
}
}
}
using System;
using System.Web.Mvc;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Web.Mvc;
namespace Opten.Modules.Web.Mvc
{
public abstract class ModulesViewPage<TModel> : UmbracoViewPage<TModel> where TModel:PublishedContentModel
{
// maps model
protected override void SetViewData(ViewDataDictionary viewData)
{
viewData.Model = (TModel)Activator.CreateInstance(typeof(TModel), new object[] { viewData.Model });
// set the view data
base.SetViewData(viewData);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment