Cross site linking

I’m documenting this here, in hopes that it helps someone else, but also because I often search for something here and my past-self says something that my future-self finds useful:

We maintain both a mobile site and a regular web presence from the same content, but published via two different sites in Rhythmyx (7.0.3). I created this macro to create a link from any given page in the main site, to it’s counterpart in the mobile site:

<code>
#macro(mobileVersionLink)##creates a link to the same document on the mobile site if it exists, or the home page
#set($clonedItem = $sys.assemblyItem.clone())##
$clonedItem.setSiteId($user.psoObjectFinder.getSiteGuid(359))##this is the GUID of the mobile site
#if($clonedItem.getContext() == 1)
http://mobile.domain.here.com##when in live publishing context, we must prepend the domain since the location generator produces a relative path
#end##end if
$rx.location.generate($clonedItem)##
#end
</code>

I hope others find this helpful… the key element here was recognizing that in order to set the site ID, I needed to provide the appropriate IPSGuid for the site, which was available through the psoObjectFinder.

Best of luck future-self…