Hi Daniel
You may want to take a look at the PropertyList: https://world.episerver.com/blogs/per-magne-skuseth/dates/2015/11/trying-out-propertylistt/
An alternative approach is to define the carosel item as a block which is added to the carosel block in a content area. You can see a (non production) example of this in the Alloy Demo Kit: https://github.com/episerver/AlloyDemoKit/blob/master/src/AlloyDemoKit/Models/Blocks/CarouselBlock.cs
David
Hi David,
Thanks for responding!
To provide you with some context, we're working on a series of UI components as a seperate project which we're tyring to use in Episerver.
I'm afraid that as a result, the classes we're trying to use are in a seperate assembly without a reference to Episerver so we can't use the EditorDescriptor attributes on these classes.
Is there any other method of telling Episerver how to use these classes (ViewModels)?
I assume you have some control over the views? In that case you can use a view model to emit the exact poco class you need in the view and wire up the Episerver properties using the methods suggested and a controller for the carousel block.
Yeah we do have control over the views for the blocks. Im not sure I follow what you are saying here though. Could you expand on that a bit more? Can we achieve this in a programatic way outside of the classes?
Thanks
I imagine you'd write a custom controller for your carousel block. That controller would return your Carosel class (as defined in your original post) as the view model. The view model itself would be constructed by mapping the properties from the CaroseBlock type to your Carosel type.
Psedo code for the Index method of the controller would look like this:
public override ActionResult Index(CarouselBlock currentBlock)
{
var model = new Carousel // as described by you above
{
Items = // your Carosel items
startindex = // start index
};
return PartialView("Carousel", model);
}
you can then then construct your Carosel in the view using your populated Carosel class (which I assume is coming from your external project and cannot be changed)
Hi,
We're trying to integrate external components into Episerver blocks. Below is an example of this with standard classes.
Do we have to write custom adapters for each component class to convert them into Episerver blocks, or is there a way to do that with Episerver out of the box?
Executing the code above gives us the following error:
Type 'Models.Blocks.Carousel' could not be mapped to a PropertyDefinitionType
Thanks!