Dec 17, 2012 at 2:27 AM
Edited Dec 17, 2012 at 2:30 AM
|
Hi,
I have a custom content type and it's rendered as the following for summary view
<article class="content-item @contentTypeClassName">
<header>
@Display(Model.Header)
@if (Model.Meta != null) {
<div class="metadata">
@Display(Model.Meta)
</div>
}
</header>
@Display(Model.Content)
@if(Model.Footer != null) {
<footer>
@Display(Model.Footer)
</footer>
}
</article>
The @Display(Model.Content) contains some numeric, enumerable and input fields. Each of them is rendered in a separate p tags. I want to render them in single table. So I found an article an article which is suggested this can
be done by using some Clay wizardry to enumerate zones and then the shapes within them to find one with the specified name.
The following is the helper code
public static class ShapeHelper
{
public static dynamic Find(IShape model, string name)
{
var zones = new Dictionary<string, object>();
((IClayBehaviorProvider)model).Behavior.GetMembers(_nullFunc, model, zones);
foreach (var key in zones.Keys.Where(key => !key.StartsWith("_")))
{
var zone = zones[key] as IShape;
if (zone == null || zone.Metadata.Type != "ContentZone")
{
continue;
}
foreach (IShape shape in ((dynamic)zone).Items)
{
if (shape.Metadata.Type == name)
{
return shape;
}
}
}
return null;
}
private static readonly Func<object> _nullFunc = () => null;
}
and my view code are:
@foreach(var item in Model)
{
@ShapeHelper.Find(item, "Parts_ZenGallery.Summary")
}
But I’m getting an error as stated below
Unable to cast object of type
'IShapeProxy274846b39fc94a98abccc141a9b19d47' to type
'ClaySharp.IClayBehaviorProvider'
Does anyone know how to resolve this error or any other suggestion to resolve my rendering issue?
Thank you
muges
|