Copied to clipboard

Flag this post as spam?

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


  • CodeMaster2008 151 posts 184 karma points
    Apr 27, 2011 @ 15:24
    CodeMaster2008
    0

    How to get XPath DropDownList to list child nodes?

    Hi there;

    Since I'm not good with XLST i'm having a hard time to figure this one out.
    I have a node of type "PhotoGallery" which has subnodes of type "Photo". Something like

    PhotoGallery
      |----Photo1
      |----Photo2

    The idea is to have a DropDownList inside "Photogallery" with a list of all of its "Photos", so I can pick one to use as a thumbnail.

    The problem is that I can't figure out a XPath Expression that will return the child nodes of type "Photo", I tried the one bellow (and many others) but it didn't work:

    $currentPage//node [@nodeTypeAlias = 'Photo']

    I really appreciate any help.
    Thanks in advance.

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 27, 2011 @ 15:39
    Tom Fulton
    0

    Hi,

    "node" is the old schema and is no longer used, instead you can replace it with the nodeTypeAlias you are looking for

    Ex:

    $currentPage/Photo [@isDoc]

    -Tom

  • CodeMaster2008 151 posts 184 karma points
    Apr 27, 2011 @ 15:47
    CodeMaster2008
    0

    Hey Tom;

    Thanks man but that is still returning empty.
    I'm using the uComponents XPath DropDownList:
    http://ucomponents.codeplex.com/wikipage?title=XPathDropDownList&referringTitle=Documentation

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Apr 27, 2011 @ 15:49
    Hendy Racher
    0

    Hi CodeMaster2008,

    Which version of Umbraco are you using ? Your XPath expression looks fine for the legacy schema, but if you're using the latest schema (found in 4.5+) then the following should work:

    $currentPage//Photo

    or if the current page is unpublished and hence not in the Xml:

    $ancestorOrSelf//Photo

    HTH,

    Hendy

  • CodeMaster2008 151 posts 184 karma points
    Apr 27, 2011 @ 16:05
    CodeMaster2008
    0

    Hey,

    I'm sorry man, it does work. The reason it is returning empty is because I have the umbracoNaviHide property set to false on al Photos, since i don't want the photos to appear in the submenus.

    The question now is how can i force this documents to appear?

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 27, 2011 @ 16:07
    Tom Fulton
    0

    The umbracoNaviHide property shouldn't affect anything in the XPath statement above, you'd have to speficially add a condition for that in the XPath if you wanted to hide them.

    Are the photos and photogallery page published?

    -Tom

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Apr 27, 2011 @ 16:10
    Hendy Racher
    0

    Hi CodeMaster,

    The umbracoNaviHide property shouldn't interfere with anything - is the Photo Gallery and the Photo child nodes published ? (The XPath DropDownList will only work with published nodes, as these are the only nodes in the Xml)

    HTH,

    Hendy

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Apr 27, 2011 @ 16:12
    Hendy Racher
    0

    Hi Tom, Snap! you're obviously much quicker at replying :)

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 27, 2011 @ 16:17
    Tom Fulton
    0

    Not much else to do while I am staring at blue bars progressing across the screen :)

  • CodeMaster2008 151 posts 184 karma points
    Apr 27, 2011 @ 16:25
    CodeMaster2008
    0

    That's weird.
    here is the thing:

    The "Photos" are created via code - we unzip a file, create a document for each picture and publish it.
    The partial code used to publish the photos is this:

    ' create document
    Dim imageDocument As Document = Document.MakeNew(mediaDocumentName, DocumentType.GetByAlias("Photo"), currentUser, parentId)

    [...]

    ' publish document
    imageDocument.Publish(imageDocument.User)
    umbraco.library.UpdateDocumentCache(imageDocument.Id)

    So, the document "appears" to be published, it even shows int he Properties Tab:
    Publication Status: Last published: 4/27/2011 [unpublish button].

    However, if I go ahead and manually publish it again, it works.
    So, isn't calling Document.Publish(User) not enough to publish the document?

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 27, 2011 @ 18:00
    Tom Fulton
    1

    That should be enough to publish it.  Is the PhotoGallery page fully published at the time you are publishing the Photos?  How/where are you calling this code?  Are you perhaps calling it from an AfterPublish of the PhotoGallery page?  There is an issue with that if so.

    You might try checking the umbracoLog table after running that code, most likely there will be some sort of error that might reveal an issue.

     

  • CodeMaster2008 151 posts 184 karma points
    Apr 28, 2011 @ 15:45
    CodeMaster2008
    0

    Hi Tom;

    I created a custom data type which is an upload control and added this data type to the PhotoGallery page.
    I'm using the FileUploadComplete event of the upload control to unzip the file and create the Photo documents.

    I'm not sure of the page/document life cicle here but maybe the FileUploadComplete event is being called before the PhotoGallery is published right?

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 28, 2011 @ 21:36
    Tom Fulton
    0

    Hi,

    I suppose that's possible.  Do you get the same issue if you first save/publish the page, then return to it and do the File Upload?  Perhaps you could add some type of check in the datatype to only render if the page is fully published.

    -Tom

Please Sign in or register to post replies

Write your reply to:

Draft