Try our conversational search powered by Generative AI!

Create a block within a category and by default load a list Object

Vote:
 

Hello good everyone.
I present my case.

I have a .net 4.6.1 project with cms and commerce

I need to create a block within a category and load a list by default, to speed up the work of the editors.

for this, I have created a block that contains

public virtual IList<FlagsOrderModel>

where

public class FlagsOrderModel
    {

        [Display(Name = @"Name", Order = 10)]
        public virtual string Name { get; set; }

        [Display(Name = @"Url", Order = 10)]
        public virtual Url Url{ get; set; }

    }

my problem is that i can't load this blocke with predefined data.

[Display(Name = @"Brand List", Order = 10)]
[EditorDescriptor(EditorDescriptorType = typeof(CollectionEditorDescriptor<FlagsOrderModel>))]
[UIHint("ListStringMarks")]
public virtual IList<FlagsOrderModel> Flags{ get; set; }

1st to be able to load the block with predefined flags
and second I would try to make this list automatic
making a select of the category in which this block is created and obtain a list of product brands.

can someone give me an idea?

I have tried with

[UIHint("ListStringFlags")]


[EditorDescriptorRegistration(TargetType = typeof(string), UIHint = "ListStringMarks")]
    public class SituationMultipleEditorDescriptor : EditorDescriptor
    {
        public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
        {
            SelectionFactoryType = typeof(SituationMarcasFactory);
            ClientEditingClass = "epi-cms/contentediting/editors/SelectionEditor";

            base.ModifyMetadata(metadata, attributes);
        }
    }
    public class SituationMarcasFactory : ISelectionFactory
    {
        public IEnumerable<ISelectItem> GetSelections(ExtendedMetadata metadata)
        {
            var situation = new List<SelectItem>();
            situation.Add(new SelectItem() { Value = "Adidas", Text = "Adidas" });
            situation.Add(new SelectItem() { Value = "Nike", Text = "Nike" });

            return situation;
        }
    }

Without any result.

#289160
Oct 13, 2022 14:26
Vote:
 

The targe type of your editor descriptor does not match your property type.

#289983
Oct 14, 2022 13:52
Vote:
 

this has been a mistake

even with this correct. I can't get the list to load the predefined data by default.

[UIHint("ListStringFlags")]


[EditorDescriptorRegistration(TargetType = typeof(string), UIHint = "ListStringFlags")]
#289985
Oct 14, 2022 13:55
Vote:
 

I don't really understand exactly what you are trying to do.

A couple examples.

A dropdown list property:

Property list / collections editor:

And them combining them:

#290112
Edited, Oct 16, 2022 4:09
Daniel - Oct 17, 2022 7:38
Thank you very much!!!

This has really helped me a lot.
Tomas Hensrud Gulla - Oct 17, 2022 11:44
Nice, you are welcome 😁
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.