Copied to clipboard

Flag this post as spam?

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


  • bob baty-barr 1180 posts 1294 karma points MVP
    Mar 20, 2015 @ 16:31
    bob baty-barr
    0

    So... how would I use this IN a custom grid docType

    So, using both your AWESOME new packages together... how would i get at the properties of a nested content item in a grid docType? I can get the name like this... but how do i list the custom properties?

    @inherits Umbraco.Web.Mvc.UmbracoViewPage
    
        @{ 
            var items = Model.GetPropertyValue>("CarouselItems");
    
            foreach(var item in items) { 
                // Do your thang...
            

    @item.Name

    } }
  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Mar 20, 2015 @ 16:43
    Lee Kelleher
    103

    Hi Bob,

    Thanks for the praise! :-)

    With accessing the Nested Content values, you can use the IEnumerable<IPublishedContent> type.

    var items = Model.GetPropertyValue<IEnumerable<IPublishedContent>>("CarouselItems");
    

    Then inside the loop, you can access the item's inner properties using GetPropertyValue<T>:

    foreach(var item in items)
    {
        // Do your thang...
        @item.Name
    
        @item.GetPropertyValue("propertyAlias")
        // ... or ...
        @(item.GetPropertyValue<string>("propertyAlias"))
    }
    

    Hope this helps?

    Cheers,
    - Lee

  • bob baty-barr 1180 posts 1294 karma points MVP
    Mar 20, 2015 @ 16:50
    bob baty-barr
    0

    BOOM!

    building a carousel now ;)

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Mar 20, 2015 @ 16:54
    Lee Kelleher
    7

    OH YEY!

  • bob baty-barr 1180 posts 1294 karma points MVP
    Mar 20, 2015 @ 17:39
    bob baty-barr
    0

    okay, continuing on... i know this is programming 101, but me != developer...

    how do you avoid the object not set to instance with a call like this?

    rotLink = item.GetPropertyValue<IPublishedContent>("carouselContentLink");

    carouselContentLink is a content picker????

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Mar 20, 2015 @ 23:05
  • Jason Prothero 422 posts 1243 karma points c-trib
    Mar 27, 2015 @ 00:12
    Jason Prothero
    0

    Bob, I had the same problem with a Nested Content inside a DocType Grid Editor.  I could get the ID using GetPropertyValue, but GetPropertyValue<IPublishedContent> returned null.

     

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Mar 27, 2015 @ 09:43
    Matt Brailsford
    0

    Hey Jason,

    OTB NC, doesn't come with any value converters installed so to have a link node return IPublishedContent, you need to have a value converter defined that does this. The easiest way to do this for common datatypes is to install Jeavons Umbraco Core Property Value Converters package here https://our.umbraco.org/projects/developer-tools/umbraco-core-property-value-converters. This should then return you the IPublishedContent you require.

    Matt

  • Jason Prothero 422 posts 1243 karma points c-trib
    Mar 31, 2015 @ 23:01
    Jason Prothero
    0

    Yep, I thought I nugetted that package in, but there must have been an issue I missed.  Installed it as a package and it worked great.

    Sorry about that!

     

    Thanks,
    Jason 

Please Sign in or register to post replies

Write your reply to:

Draft