Obtain slotted item folder location

I am trying to obtain a slotted items’ folder location. So far this is what I have:


#if($sys.currentslot.relresults.size() != 0)##
$user.psoFolders.getParentFolderPath($sys.currentslot.relresults.get(0))##
#end##

This produces the location of the page that contains the slot and not the slotted item folder location.

Alternatively I tried creating a shared template and linking it though the slot. This produced the same file path as before (the path to the page containing the slot):

Binding Variable:


$user.psoFolders.getParentFolderPath($sys.AssemblyItem)##

Can I do a lookup on the folderid to show me the folder path?

I believe you will need to clone the assembly item of the item in the slot…
Something like the following may work…note i haven’t actually tried it out…


#if($sys.currentslot.relresults.size() != 0)##
## cloning assembly item of the node
#set($currItemAssemblyItem = $sys.currentslot.relresults.get(0).clone())##
## not sure if the following line is needed..you  may not need it as you have the assembly item of the first item in the slot above....
$currItemAssemblyItem.setNode($sys.currentslot.relresults.get(0).getNode())##
$user.psoFolders.getParentFolderPath($currItemAssemblyItem)##
#end##

Thanks Jitendra,

I tried your suggestion (with and without the setnode) but I am still receiving the same path. I double checked that it is reading the right slot and is pointing to the correct content id.

Stephen,

Try using the macro I posted to the snippets repository forum: here

You should then be able to do something like:

#initcustomslot( 'RelatedArticle_Slot' '' )
#foreach( $assemblyItem in $sys.currentslot.assemblyItems )
$user.psoFolders.getParentFolderPath($assemblyItem)
#end
#endslot( 'RelatedArticle_Slot' )

Rushing,

This is still giving me the publication of the containing slot, not the slotted item. Thanks for your help.

Ok…this may be a silly question, but the function that you are using is “getParentFolderPath”…does pso provide a “getFolderPath” (ie perhaps $rx.location.folderPath / $rx.location.path or another build in function)?

With the getParentFolderPath, the parent of the slot should be the current item (i think) and hence you are getting the results that you are…

Since i haven’t used that function, i’m not sure exactly what getParentFolderPath does, but from the name i wouldn’t be surprised if that’s what it is doing…

Actually, There is a getPath() function for an item that returns exxentially <path seperator><system title>.

so the full path to an item would be:

${user.psoFolders.getParentFolderPath($item.getGuid())}${item.getPath()}

Code for this might look like:

#initcustomslot( 'RelatedArticle_Slot' '' )
#foreach( $assemblyItem in $sys.currentslot.assemblyItems )
${user.psoFolders.getParentFolderPath($assemblyItem)}$assemblyItem.getPath()
#end
#endslot( 'RelatedArticle_Slot' )

Note: I may have mixed up the item and assembly item classes, so if this code doesn’t work, try doing something with $sys.item in a sub-template.