Copied to clipboard

Flag this post as spam?

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


  • Craig Duffield 11 posts 31 karma points
    Aug 28, 2012 @ 12:04
    Craig Duffield
    0

    Documents - Getting all of a documents children (as document) of a certain type only!

    Hi guys,

    I need help to find all the child documents of a document but of a certain type.

    I can do this easily with nodes but with documents it seems much harder to achieve.

    I can do the following in nodes:

    For Each child As Node In nodeContactSet.Children

                If child.NodeTypeAlias = "DocTypeAlias" Then
                   'Do something

                End If

    Next

    Is there an easy way to do the same thing with documents ?

  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 28, 2012 @ 12:52
    Fuji Kusaka
    0

    Hi Craig,

    By Documents you mean document type or from Media folder?

    If from media folder you could create a new Media Type "Documents" under the Settings section which you will be using in the Media Section to upload your documents.

    Your XSLT will be something like

    <xsl:variable name="mediapickerproperty" select="$currentPage/dcoumentFolder"/>
    <xsl:for-each select="umbraco.library:GetMedia($mediapickerproperty, 1)/Documents">
    ..
    </xsl:for-each>

     

    Hope it makes helps

    //Fuji

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Aug 28, 2012 @ 13:04
    Hendy Racher
    1

    Hi Craig,

    If you're using Umbraco 4.8+ or have uComponents installed how about:

    Document parentDocument = new Document(123);
    foreach (Document childDocument in parentDocument.GetChildDocumentsByType("docTypeAlias"))
    {
    // Do Something...
    }
    

    (The above uses uQuery extension methods, which can be found in the umbraco namespace if using 4.8+ or otherwise within uComponents.Core.uQueryExtensions)

    HTH,

    Hendy

  • Craig Duffield 11 posts 31 karma points
    Aug 28, 2012 @ 13:16
    Craig Duffield
    0

    Thanks for your help guys. I particularly like your solution Hendy and it works brilliantly well.

    Thanks,

    Craig

Please Sign in or register to post replies

Write your reply to:

Draft