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:
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:
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?
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.
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)
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)
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.
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?
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.
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.
Hi,
"node" is the old schema and is no longer used, instead you can replace it with the nodeTypeAlias you are looking for
Ex:
-Tom
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
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:
or if the current page is unpublished and hence not in the Xml:
HTH,
Hendy
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?
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
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
Hi Tom, Snap! you're obviously much quicker at replying :)
Not much else to do while I am staring at blue bars progressing across the screen :)
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:
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?
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.
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?
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
is working on a reply...