Copied to clipboard

Flag this post as spam?

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


  • Fernando Camillo 41 posts 82 karma points
    Apr 15, 2011 @ 16:58
    Fernando Camillo
    1

    UserControl datatype: how to get it's tab?

    Hi again.

    I made a user control to use as a datatype. It's working fine. Is there a way to get it's tab name? (the tab the datatype is in in the current document edition)

    Thanks.

    Fernando
    Umbraco 4.5.2 for .Net 3.5
    MySQL
    Windows Server 2003 64 bits

  • Sebastiaan Janssen 5045 posts 15476 karma points MVP admin hq
    Apr 16, 2011 @ 14:38
    Sebastiaan Janssen
    0

    Probably not, you may be able to find something in the ContentType (umbraco.cms.businesslogic.ContentType) class, but I doubt it.

    If you do find something, I'd love to know!

  • Dirk Seefeld 126 posts 665 karma points
    Jun 06, 2014 @ 17:36
    Dirk Seefeld
    0

    Hi, I could not find a function in the core APIs.
    But the following works for me in version 6.2.1:

    namespace MyDomain.DataTypes
    {
    public class MyCustomDataEditor : Control, IDataEditor { private class PropAndTabNames { public string TabName { get; set; } public string PropName { get; set; } } private PropAndTabNames GetPropAndTabNames() { PropAndTabNames rVal = null; int nodeId = 0; if (int.TryParse(UmbracoContext.Current.HttpContext.Request.QueryString["id"], out nodeId) && nodeId > 0) { var contentService = ApplicationContext.Current.Services.ContentService; var content = contentService.GetById(nodeId); var tabs = content.ContentType.PropertyGroups; foreach (var tab in tabs) { var props = tab.PropertyTypes; foreach (var prop in props) { if (this.ID == "prop_" + prop.Alias) { rVal = new PropAndTabNames(); rVal.TabName = tab.Name; rVal.PropName = prop.Name; break; } } } } return rVal; }
    ...
    protected override void OnLoad(EventArgs e) { base.OnLoad(e);
    ...
    var propTabNames = GetPropAndTabNames();
    ...
    }
    }
    }

    Of course the rest of the DataEditor code is omitted;-)

    Yours
    Dirk 

  • Dirk Seefeld 126 posts 665 karma points
    Jun 06, 2014 @ 18:01
    Dirk Seefeld
    0

    @Fernando: Sorry I have ignored that you are using version 4.5.2. The solution might by similar with the old API. You'll find a description on stackoverflow.com:

    http://stackoverflow.com/questions/13334319/getting-all-the-properties-on-tab-in-umbraco

    Dirk

Please Sign in or register to post replies

Write your reply to:

Draft