How to link a collection of custom IContent types under a page?

Vote:
 

Hello,

I'm a bit lost here with this new EpiServer 7 and its IContent model. Could someone please explain me some things.

Here's an example what I'm trying to do. I want a list of services somewhere and I need to be able to create (service) stations and link services to them.

    public class Service : IContent
    {
        // IContent boilerplate
        ...

        // Some properties like
        public virtual bool UseInSearch { get; set; }
    }

    [ContentType(DisplayName = "StationPage", GUID = "7bc4dc60-fad0-43e4-8ed3-4f5b697aabf1", Description = "")]
    [AvailablePageTypes(IncludeOn = new[] { typeof(StationFolderPage) })]
    public class StationPage : BasePageData
    {
        // Some properties like station's address and phone number
        ...

        // Here I need a list of Services
    }

In Epi6 I would've created Service-class as Page Type and then custom property to hold a list of Services but now in Epi7 I don't know how to do this. I want to create Service as IContent, since it doesn't have a template and is never rendered to user.

I went through the API but found nothing like ContentReferenceCollection, allthough I found ContentReference. I tried to use PageReferenceCollection but that keeps saying me that it cannot be mapped to a PropertyDefinitionType. I'm not even sure if this is the correct way to link custom IContent stuff to the pages.

Any help will be greatly appreciated.

#65010
Jan 17, 2013 14:19
Vote:
 

Without having tried it my self bit could you use a property of type LinkItemCollection?

You could then use IPermanentLinkMapper to get permanentlinks to your items which you then can store in the collection.

We have in our backlog a story that we should support collections of types (e.g. String, ContentReference etc) but I cant promise anything if/when that will be available.

#65012
Jan 17, 2013 15:13
Vote:
 

Unless I've misunderstood the problem I would use a ContentArea.

#65020
Jan 17, 2013 16:42
Vote:
 

I didn't think of ContentArea but of course that is a much better alternative. It is much nicer to work with than LinkItemCollection.

#65028
Jan 17, 2013 20:14
Vote:
 

Ah. Thank you. ContentArea seems to do the trick.

Next thing is that editor needs to be able to drag my custom Service contents to the ContentArea. I thought about writing a gui plugin which lists all the custom IContents on the site, just like the one that lists Blocks. I'll get back to you if and when I stumble to any new problems :)

-Marko

#65038
Jan 18, 2013 6:56
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.