Generate link to a Content Item other than the current one

To create a link to the current content item, I’ve used one of the following:

[ul]
[li]$rx.location.generate($sys.assemblyItem)
[/li][li]$rx.location.generate($sys.assemblyItem, “template_name”)
[/li][/ul]

However, I’d like to link from one content item to another one. How would I accomplish that?

Do you mean an arbitrary content item, or an item in a slot on the same page or with some sort of relationship with the current content item?

[QUOTE=Gandalf;17815]To create a link to the current content item, I’ve used one of the following:

[ul]
[li]$rx.location.generate($sys.assemblyItem)[/li][li]$rx.location.generate($sys.assemblyItem, “template_name”)[/li][/ul]

However, I’d like to link from one content item to another one. How would I accomplish that?[/QUOTE]

An arbitrary content item. I’ve done a little work with content items included via a slot on the same page but arbitrary content items with no relationship is something new for me… Sorry, I’m new to developing in the CMS so I appologize for the newbie question.

No worries. It’s actually a need I had not too long ago. As usual w/ Percussion, there are probably a number of different ways to do this. The way we’ve done it on our project is via an autoslot. We have an autoslot called slot findItemByFolderAndSystemTitle,which takes to two parameters - site_path and mySysTitle. The slot takes in these parameters and does a query which looks like this:

SELECT rx:sys_contentid, rx:sys_contentstartdate FROM rx:<content type>,rx:<content_ type>… where jcr:path like :site_path and rx:sys_title=:mySysTitle

For each content type brought in, you will need to tell the slot to render it with a snippet template that does nothing but generate the URL for the content item, using $rx.location.generate($sys.assemblyItem,<template name>), just as you have done before.

You then call this slot from your templates to generate links to any content item, like so:
#slot(“findItemByFolderAndSysTitle” “” “” “” “” “template=<template name>&mySysTitle=<system title>&site_path=//Sites/<folder1>/<folder 2>/<system title>”)

Voila. Let me know if that doesn’t make sense or if I’ve misunderstood your question.

Duane

Hi Duane,

Thanks for your help! I’d have responded sooner had I not been pulled off this project for over a month to work on a last minute release of a new site. As for your solution, due to a change in requirements I found that I could solve our original issue by referencing the file externally. However, using an autoslot has worked great in another area where we have a navigation menu for our glossary. The only detail I’m stuck on is hilighting the character in the navigation menu for the page that is currently displayed. I thought I could pass this from the “parent” template to the “child” template as a parameter, like so:

#set($curr_char = $sys.item.getProperty(“glossary_character”).String)
#slot(“SlotName” “” “” “” “” “site_path=//Sites/SiteName/glossary&curr_char=${curr_char}”)

However, I’m unsure how to reference the “curr_char” value when I’m in the “child” template. Am I on the right track or should I be doing this some other way?

Thanks again for the help.

Good morning Mark.

You are on the right track, but to pass this value through to the items rendered in the Slot, you’d need to use a binding on the parent page. If you simply set $curr_char as a binding on the parent template, you can simply reference that binding value in the child snippets without even passing it through as a parameter. Give that a shot.

M

Hi Michael,

Is it possible for these values to go the other way? Can a child template pass values back to the parent?