Umbraco Export to .NET – Skips properties in Inherited Tabs
18/08/2011 Leave a Comment
Place a property of any type in the Generic tab and it always exports, move it to a tab inherited from the parent docType and it’s excluded from the export.
Seeing this issue in v.4.7, issue occurs with our without using the autoexport2dotnet (http://our.umbraco.org/projects/developer-tools/autoexport2dotnet) – because it’s an issue in the core export logic.
This is caused by what seems like a bug in the umbraco.presentation project, in \umbraco\presentation\umbraco\dialogs\ExportCode.aspx.cs in the GenerateProperties method.
private object GenerateProperties(DocumentType dt)
{
var sb = new StringBuilder();
foreach (var pt in
dt.getVirtualTabs.Where(x => x.ContentType == dt.Id).SelectMany(x => x.GetPropertyTypes(dt.Id, true))
.Concat(dt.PropertyTypes.Where(x => x.ContentTypeId == dt.Id /* don't limit this to generic tab! && x.TabId == 0*/)).Distinct()
)
{
//...loops and writes properties here
In the above the bit to remove is the “x.TabId == 0″ that I’ve commented out – this limits the properties rendered to the first tab (the generic properties).
I have only tested this quickly, but seems to work perfectly – I will update here if I find any issues – cheers!
PS. Please note that this method has changed between version 4.7.0 and 4.7.1 because of a separate issue – however for both version removing the “x.TabId == 0″ solves this issue.
If you include abstractions (interfaces) in your export, you need to make the same amend to the GenerateAbstractProperties method, so remove the check for TabId == 0 and make the selection distinct.
I wrote this solution here as well: http://our.umbraco.org/forum/templating/templates-and-document-types/18730-%27Export-to-net%27-not-including-properties-on-inherited-tabs