3

I´m using Sitecore and Glass Mapper, and I´d like to know if the following is possible:

I have a Sitecore Item, which has 5 fields. These fields are CSS classes (height, width, effects, icons, etc). It´s a metro style webpage, so the idea is to allow the user to change some settings on the fly.

Instead of making 5 different properties, and access each field, I´d like to know if there is a way to return those 5 fields as a list, or a string.

public class CSSClass
{
    [SitecoreField]
    public virtual Image Name { get; set; }

    [SitecoreField(FieldName = "CSS Class")]
    public virtual string CSSClass { get; set; }
}

That would be my Model for each setting. And this is my Tile:

public class WelcomeTile
{
    [SitecoreField]
    public virtual string Title { get; set; }

    public virtual IEnumerable<CSSClass> CSSClasses { get; set; }
}

And I´d like to access those in the property CSSCLasses, instead of going one by one like this, for example:

[SitecoreField]
public virtual CSSClass Hieght { get; set; }
[SitecoreField]
public virtual CSSClass Icon { get; set; }
[SitecoreField]
public virtual CSSClass Width{ get; set; }
[SitecoreField]
public virtual CSSClass Effect { get; set; }
4

1 回答 1

2

我同意上面的评论,我不确定你的数据结构是如何工作的。但是,任何自定义数据映射都可以使用自定义数据处理程序来实现,请参阅此博客文章:

http://glass.lu/Mapper/Sc/Tutorials/Tutorial19

于 2014-03-15T09:17:38.263 回答