Copied to clipboard

Flag this post as spam?

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


  • schlubadub 102 posts 617 karma points
    Mar 19, 2015 @ 02:23
    schlubadub
    0

    Get all properties from a tab

    Sorry for the double-post. I originally posted my question in the "Using Umbraco 7" area, but perhaps it's in the wrong area as I haven't had any response at all.

     

    Does anyone know how to get all the properties from one tab at once(Umbraco 7.2)? i.e. without having to call each property individually by name.

    More details here: https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/63227-Get-all-properties-from-a-tab

  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Mar 19, 2015 @ 15:52
    Tim
    0

    From your other post, it looks like you want to do this on the front end? If so, the front end doesn't store the tabs, as they're just used for organising things in the back office.

    The only way to access the tabs is to use the back office ContentService, but you really don't want to do that on the front end of your site, as it hits the database, rather than using the Umbraco Cache.

  • schlubadub 102 posts 617 karma points
    Mar 20, 2015 @ 03:15
    schlubadub
    0

    Hi Tim,

    Thanks for replying. Yeah, I'm using this for display purposes. It looks like tabs for properties are stored as "propertyTypeGroupId" in the table cmsPropertyType. It's strange that the property type group isn't accessible anywhere on the front-end...

    It looks like it used to be accessible via a few different methods such as:

    umbraco.cms.businesslogic.propertytype.PropertyType.GetPropertyTypesByGroup(System.Int32)

    But this has a warning: 'umbraco.cms.businesslogic.propertytype.PropertyType' is obsolete: '"Use the ContentTypeService instead"'

    I haven't found any corresponding function in the ContentTypeService as of yet...

     

    I can retrieve the property types by group by writing my own query, but it seems a bit horrible joining with 4 tables just to get all the properties and a group and verify that they have a value. I might explore this a bit further...

    DECLARE @CurrentPageNodeID int
    SET @CurrentPageNodeID = 1069  --This can be passed in as CurrentPage.Id
    
    DECLARE @PropertyGroupName varchar(50)
    SET @PropertyGroupName = 'Social'  --Tab Name of properties to get
    
    SELECT  PROPTYPE.[id]
        ,PROPTYPE.[Alias]
        ,PROPTYPE.[Description]
        ,PROPTYPE.[Name]
        ,PROPDATA.[dataNvarchar]
    FROM [dbo].[cmsPropertyData] PROPDATA 
    JOIN [dbo].[cmsPropertyType] PROPTYPE ON PROPTYPE.id = PROPDATA.propertytypeid
    JOIN [dbo].[cmsPropertyTypeGroup] PROPGROUP ON (PROPGROUP.[id] = PROPTYPE.propertyTypeGroupId                                                                                       AND (PROPGROUP.[text] = @PropertyGroupName OR @PropertyGroupName = ''))
    JOIN [dbo].[cmsDocument] DOC ON (   PROPDATA.versionId = DOC.versionId
                        AND DOC.nodeId = @CurrentPageNodeID 
                        AND DOC.newest = 1
                        AND DOC.published = 1)
    WHERE PROPDATA.[dataNvarchar] <> ''
    ORDER BY PROPTYPE.[sortOrder]
  • schlubadub 102 posts 617 karma points
    Mar 23, 2015 @ 01:51
    schlubadub
    0

    Hi Tim,

    Would you know how to do this using the ContentService? Caching isn't really an issue as I can always cache it myself...

    Cheers,

    Brian

  • schlubadub 102 posts 617 karma points
    Apr 01, 2015 @ 04:15
    schlubadub
    0

    bump

  • schlubadub 102 posts 617 karma points
    Apr 09, 2015 @ 15:30
    schlubadub
    100

    Just to update my own thread, I still haven't found an answer for getting all the properties from a tab, and I suspect I never will without someone intimately familiar with Umbraco assisting.

    But I've found that can achieve exactly what I want by approaching the problem differently... I've been playing with LeBlender to create custom property edtors for the grid, and using it I can create nifty "lists" of items but I can also get the count for the number of items (essential for responsive positioning of elements).

    So for the "Social" example in my original post, I just create a property editor with "Link" (a URL) and "Type" (selected from a drop-down to indicate the type it is (Facebook, Twitter etc) which I can either use as a class to show a specific icon, or to select a specifc element should I wish to. Adding a new type is a simple matter of adding to the Type drop-down, and it will display on the front-end immediately. This is far, far better that having to add a whole new property to a tab each time and then needing to edit all the templates to use it.

    So thankyou me, for helping me! :P And also to LeBlender for saving my skin at the 11th hour!

Please Sign in or register to post replies

Write your reply to:

Draft