Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • ja 3 posts 23 karma points
    Apr 15, 2013 @ 12:23
    ja
    0

    uSiteBuilder with DAMP

    Hi,

    I've just started looking at uSiteBuilder with Umbraco 6 and was wondering what's the correct way to create a documenttype that uses DAMP and ideally get's the data from umbraco.config.

    I thought perhaps creating a Converter which just returns an int then on the front end it could get all properties required via a helper or perhaps do documenttype could have a custom object with all details populated or another way?

    With any approach though would it be possible to get the data from the config file to eliminate db hits?

    Thanks

     

     

  • Shannon 24 posts 45 karma points
    May 14, 2013 @ 16:30
    Shannon
    0

    You can use a convertor. You will have to save you DAMP to store the ID and not the XML

    [DocumentTypeProperty(UmbracoPropertyType.Other, OtherTypeName = "Banner Image", CustomTypeConverter = typeof(IMediaListConverter))]
    public List<IMedia> BannerImageList { get; set; }
    public class IMediaListConverter : ICustomTypeConvertor
        {
            public Type ConvertType
            {
                get
                {
                    return typeof(IList<IMedia>);
                }
            }
    
            public object ConvertValueWhenRead(object inputValue)
            {
                if (inputValue != null && !string.IsNullOrEmpty(inputValue.ToString()))
                {
                    var service = ApplicationContext.Current.Services.MediaService;
    
                    var list = new List<IMedia>();
                    foreach (var id in inputValue.ToString().Split(','))
                    {
                        var media = service.GetById(int.Parse(id));
                        if (media != null)
                        {
                            list.Add(media);
                        }
                    }
    
                    return list;
                }
                return null;
            }
    
            public object ConvertValueWhenWrite(object inputValue)
            {
                throw new NotImplementedException();
            }
        }
Please Sign in or register to post replies

Write your reply to:

Draft