I want to be able to list all items in the same folder as the list. I thought this would be easy to do using a JCR query but it doesn’t return any results.
My query is
select rx:sys_contentid, rx:sys_folderid, jcr:path, rx:sys_contentstartdate from rx:spctGeneralPage where rx:sys_folderid = 320
It seems that I can’t use the rx:sys_folderid in the where clause. Is there another way of doing this?
Yes, the jcr:path is a path, and it doesn’t work with an id.
The simplest way to get the folder path for an existing item is to use the
psoFolders function (in the PSOToolkit)
should return the path of the current item. Put this in a binding variable and use the binding variable in your JCR Query.
I believe that there is an example of this in the 6.5 developers training course, so if you have the training manual you should be able to find a worked example.
All working now, I don’t I installed the toolkit correctly as the function wasn’t appearing. Re-installed and all working fine.
The JCR queries use a pseudo property called
instead. So you could have something like this:
where jcr:path = '//Sites/myfolder/childfolder'
where jcr:\path like '//Sites/myfolder/%'
other patterns using % will work, and you can have several such clauses to select from multiple folder paths. In fact if you want a specific folder and all of it’s children you really need to do something like this:
where jcr:\path = '//parentpath' or jcr:\path like '//parentpath/%'