What is really used here?

This piece of code from the Sipke Tutorial (which is awesome by the way) confused me a little. In his lesson, he says that. Accessible allows you to add pieces of content to content types. But in the code snippet below, the Content Part is declared as .Attachable (false) and is still added to the Content Type. So there must be some other criteria that I don't understand. So what is the difference between CustomerPart and AddressPart as far as Attachable is concerned?

        ContentDefinitionManager.AlterPartDefinition(typeof(Models.CustomerPart).Name, p => p
            .Attachable()
            );

        ContentDefinitionManager.AlterTypeDefinition("Customer", t => t
            .WithPart(typeof(Models.CustomerPart).Name)
            .WithPart("UserPart")
            );

        ContentDefinitionManager.AlterPartDefinition(typeof(Models.AddressPart).Name, p => p
            .Attachable(false)
            .WithField("Name", f => f.OfType(typeof(TextField).Name))
            .WithField("AddressLine1", f => f.OfType(typeof(TextField).Name))
            .WithField("AddressLine2", f => f.OfType(typeof(TextField).Name))
            .WithField("Zipcode", f => f.OfType(typeof(TextField).Name))
            .WithField("City", f => f.OfType(typeof(TextField).Name))
            .WithField("Country", f => f.OfType(typeof(TextField).Name))
            );

        ContentDefinitionManager.AlterTypeDefinition("Address", t => t
            .WithPart(typeof(Models.AddressPart).Name)
            );

      

+3


source to share


1 answer


IIRC, a piece of content can always be type bound (for example, through ActivatingFilter<>

or by specifying it in your migrations), however, only those parts that are marked as Attachable()

will be displayed when creating content types in the admin control panel. So I think that in this case it CustomerPart

will appear when selecting pieces of content for the content type when constructing using the control panel, whereas it AddressPart

will not.



Edit: I just went through, though some of it goes through, and I think the reasoning behind this is that it AddressPart

is only bound to the content element Address

. There is one to one relationship between clients and addresses, and it makes no sense to allow the user to attach AddressPart

to other types of content, so it AddressPart

is hidden from users, but can still be connected for content items from the migration.

+4


source







All Articles