Reputation: 105
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; }
Upvotes: 3
Views: 1928
Reputation: 6518
I agree with the comments above that i am not sure about how you data structure is working. However any custom mapping of data can be achieved using a custom data handler, see this blog post:
http://glass.lu/Mapper/Sc/Tutorials/Tutorial19
Upvotes: 2