Question about: $rx.location.generate($sys.assemblyItem)
Is it possible to generate the $rx.location for an item other than the current item in the template. I need to be able to get the location for a paticular item in the template.
The default implementaiton: $rx.location.generate($sys.assemblyItem) generates only the rx.location for the current item being processed.
Is there any other similar or different way where you can find the location or content id of the item, and the $rx.location for the item gets generated.
thanks
Manvinder
This is exactly what I would like to know in post http://forum.percussion.com/showthread.php?11123-rx-location-generate(-sys-assemblyItem)-generated-link-NOT-right-when-published.
I was thinking of the $rx.location.generate() with full parameters, templateinfo/item/folderPath/filter/siteid/context, but then comes the question of “context” which should automatically use Preview under preview mode, and the right context when running a publishing edition (which specifies the assembly/delivery context). It should be automatic and NOT fixed, right? Same is true for the parameter of “templateinfo”. If omitted, it should default to the Default Page template of the corresponding content item. I am NOT sure if $rx.location.generate() with full parameters would allow default value if a parameter is omitted
Thanks, Hua
http://forum.percussion.com/showthread.php?10483-Trying-to-create-a-Simple-RSS-feed-template&highlight=.clone
You should be able to clone an assembly item, set the node to be the one you want to generate a link to, and then use the $rx.location.generate function…
The question is then which assemblyItem to clone from … In the code snippet,
#foreach($relresult in $sys.currentslot.relresults )##
#set($currItem = $relresult.getNode())##
#set($currItemAssemblyItem = $relresult.clone())##
$currItemAssemblyItem.setNode($currItem)##
#set($toParse = $rx.location.generate($currItemAssemblyItem, "snTitleLink"))
.......
You can directly use $rx.location.generate($relresult , “snTitleLink”) without cloning, making the code snippet like
#foreach($relresult in $sys.currentslot.relresults )##
#set($toParse = $rx.location.generate($relresult , "snTitleLink"))
.......
Thanks, Hua
Hua,
Good point… I think that was an artifact of when I was cloning the $sys.assemblyItem for something else. Not sure why I did it that way…