kgiszewski / Archetype

Archetype is an Umbraco 7 property editor that wraps other installed property editors.
https://github.com/kgiszewski/ArchetypeManual
MIT License
89 stars 54 forks source link

Property data NULL when looping through Archetype Properties #390

Closed HefinJ closed 7 years ago

HefinJ commented 7 years ago

If you loop through the properties of an Archetype, like this:

foreach (var property in fieldset.Properties)
{
        // this returns null
        var propertyEditorAlias = property.PropertyEditorAlias;
}

The only property data that is not null is the Alias and the Value of the property - it is impossible to identify what the property data type is, as the information is null.

kjac commented 7 years ago

Hey @HefinJ,

You define your own fieldsets, so you should know the type of properties contained within by their name?

The best practice for using Archetype is to split the rendering of each fieldset type into separate partial views (e.g. named by fieldset alias), and render the entire Archetype by looping over the fieldsets and call the appropriate partial views.

Check this page for more on rendering.

HefinJ commented 7 years ago

Hi @kjac,

I'm not rendering in this case.

I'm using an Upload field within an Archetype - but using an Upload field in an Archetype results in orphaned media items on the file system if an editor deletes a content page.

So to overcome this I've hooked into the Content EmptyingRecycleBin and Deleting Events so I can first look for any entities that have a property of type Archetype, and then within that Archetype property I want to identify which properties are of type Upload - so I can manually delete the media item - this way I can make sure there are no orphaned media items on the File System. But because the property data of an Archetype is null (or most of it) - I can't identify which properties are of type Upload.

Hope that makes sense :-)

kjac commented 7 years ago

@HefinJ is this issue still relevant?

kjac commented 7 years ago

I'm closing this issue now.