Copied to clipboard

Flag this post as spam?

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


  • Manfred Ramoser 2 posts 22 karma points
    Mar 28, 2012 @ 15:00
    Manfred Ramoser
    0

    GetDynamicContentById does nor work with subfolders

    Hello,

    I am trying to get a list of all the mediaitems and folders under a specific media items folder. To do this I use the following code:

     

    @foreach (var video in Umbraco.GetDynamicContentById("5d8deb02d30f4225a4eea01c00af3eb2").Children)

            {

                <p>@video.Name</p>

            }

    This works fine as long as the structure is like this:

     

    - Media

      - Videos (ID = "5d8deb02d30f4225a4eea01c00af3eb2")

        - Video 1

        - Video 2

     

    As soon as I create a subfolder in "Videos":

     

    - Media

      - Videos (ID = "5d8deb02d30f4225a4eea01c00af3eb2")

        - Video 1

        - this is a folder

        - Video 2

     

    The above code stops working with the following exception:

     

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

     

    Exception Details: System.ArgumentException: id

     

    Source Error: 

     

    Line 10:     

    Line 11:     <div id="mycont">

    Line 12:         @foreach (var video in Umbraco.GetDynamicContentById("5d8deb02d30f4225a4eea01c00af3eb2").Children)

    Line 13:         {

    Line 14:      

     

    Does anybody have an idea or a work around to solve this issue?

     

    Umbraco Version: 5.0.1

Please Sign in or register to post replies

Write your reply to:

Draft