Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Rich 22 posts 41 karma points
    Mar 23, 2011 @ 17:26
    Rich
    0

    'Export to .net' not including properties on inherited tabs.

    When trying to access a property on my doc type using Linq2Umbraco, I noticed that some of the properties were missing.

    Sad times.

    On investigating, I noticed that all the properties that were missing were on the same 'inherited' tab (from it's parent doc type). I moved the properties to a new temporary tab just to see if it made a difference and sure enough, they all exported fine.

    My sneaky suspicion is that this is somewhat related to any work that went on regarding the following post:

    http://our.umbraco.org/forum/core/41-feedback/11619-LINQ-2-Umbraco-expected-export-behavior

    Just wanted to see what people's opinions were and as to whether it's worth investigating a fix.

    Thanks,
    Rich 

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Mar 23, 2011 @ 18:04
    Ismail Mayat
    0

    Rich,

    I have been using http://our.umbraco.org/projects/developer-tools/autoexport2dotnet and have had no issues with inherited properties

    Regards

    Ismail

  • Thomas 49 posts 78 karma points c-trib
    Aug 18, 2011 @ 20:35
    Thomas
    1

    Yes seeing the exact same issue in v.4.7, issue occurs with our without using the autoexport2dotnet (http://our.umbraco.org/projects/developer-tools/autoexport2dotnet) - so seems an issue in the core export logic.

    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.

    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*/))
    )
    {
    //...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.

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Aug 18, 2011 @ 20:49
    Tom Fulton
    0

    Hi Thomas,

    Thanks for sharing the fix.  I think you should also post this on Codeplex so one of the devs might see it and update it in the core as well :)

    -Tom

  • Thomas 49 posts 78 karma points c-trib
    Aug 18, 2011 @ 20:53
    Thomas
    1

    Good point - that's here if anyone wants to vote: http://umbraco.codeplex.com/workitem/30419

     

  • Thomas 49 posts 78 karma points c-trib
    Aug 18, 2011 @ 21:20
    Thomas
    0

    Slight amend - need a distinct on the end, otherwise anything actually sitting in the "generic properties" tab gets duplicated:

     

           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
  • Thomas 49 posts 78 karma points c-trib
    Aug 21, 2011 @ 16:50
    Thomas
    0

    Further to the above, if you include abstractions (interfaces) in your export - the above amend also need to be done in the GenerateAbstractProperties method - so remove the TabID == 0 check, and add a Distinct() to the end.

Please Sign in or register to post replies

Write your reply to:

Draft