Messing with $rx.location.generate

In a part of our Rhythmyx-maintained site, we call $rx.location.generate($sys.assemblyitem) within rffSnTitleLink to generate the <a/> tags used for navigation.

Now I’d like to change the results of that call so that they no longer reflect the Rhythmyx folder hierarchy.

Is there an easy way of doing that? I think I could derive the URL I want to output from the content item, but that would mean links would no longer work in Active Assembly, as I’d only be outputting the Publish version of the URL, not the AA version.

Does anyone have any idea as to how I might go about messing with $rx.location.generate to give it a different output? Am I gonna have to roll up my sleeves and delve into Java to do this? :S

Sure, change the location scheme for the page template.

The item will publish to the new location, and the links in preview will still contain the correct values.

There’s no requirement that you use the “pub path” in your location schemes, but you should make sure that whatever scheme you use, it generates a unique URL for each page.

Dave

Dave,

Thanks for your help; that’s got me so far. Two problems, though:

1: How do I format the date once I get there? I can’t see any way in Velocity (that Rhythmyx is gonna support) to allow me to format the date once I get it. I tried $date.format(“yyyyMMdd”, $sys.item.getProperty(‘rx:sys_contentstartdate’)), but that doesn’t seem to want to work…

2: I don’t want to publish to the new location. I’m going to be rewriting the URLs on the other end, so I only want the links to change, not the file locations themselves.

Am I gonna need to mess with the HTTP stream on the server and change the URLs myself?

  1. Use $tools.date.format().

  2. You need to set up 2 different “contexts” with different location schemes. The “Delivery Context” generates the delivery location when publishing. The “Assembly Context” generates the links. If you look at the Fast Forward content lists, you will see that they have a parameter named “sys_assembly_context”.

The reason that we use 2 contexts is so we can publish into a delivery server where the link urls and the file locations are not the same (which is what I think is happening in your case).

Dave

Aah, that makes sense.

I’m not sure I follow the bit about Contexts, though. We have two Contexts already — a Publish context and a Site Folder Assembly context. If the Publish context decides the filepath for the actual file, does the Site Folder Assembly context decide the filepath for the links or just something to do with Active Assembly?

I’m very confused and I can’t find anything in the (somewhat meagre) documentation that points me in the right direction…

If I make the variable “expression” in the Site Folder Assembly context read:

$sys.pub_path.replaceFirst('[A-Za-z]{6}[0-9]{4}',
 $tools.date.format('yyyyMMdd', $sys.item.getProperty('rx:sys_contentstartdate')))
 + $sys.item.getProperty('rx:sys_title').String.toLowerCase().replaceAll(' ',
 '-').replaceAll('[^a-z0-9-]', '') + '.cmsx'

(which would give me the link format I want), then I get a comp.percussion.extension.PSExtensionException with the message ERROR [PSGeneratePubLocation] Problem while generating a publishing location for variant 575 and contentid 4946

Any ideas?

This is explained in the Rhythmyx Implementation Guide starting on Page 308 (Chapter 9: Configuring Publishing in the “Defining Context and Location Schemes” section).

It gives a reasonable explanation of why there are 2 different contexts. The “Site Folder Assembly Context” is in fact the Assembly context used Fast Forward.

You can use this for your site, or create a new one if you wish.

BTW, this section of the RIG also describes how to troubleshoot a Location Scheme, which seems appropriate to your followup question.

Dave

[QUOTE=Owen Blacker;969]If I make the variable “expression” in the Site Folder Assembly context read:

snip snip snip

(which would give me the link format I want), then I get a comp.percussion.extension.PSExtensionException with the message ERROR [PSGeneratePubLocation] Problem while generating a publishing location for variant 575 and contentid 4946

Any ideas?[/QUOTE]

This is way too complicated to debug all at once. Try it in small increments (test one expression at a time) using the method described on page 319 of the Rhythmyx Implementation Guide.

Aaaah, I think I’ve overlooked that documentation too, which would explain my frustration.

Thanks; I’ll dig that doc out and take a look. Fwiw, the expression isn’t all that complicated, it’s only the date formatting part that’s different from the current expression, so I’m pretty sure it’s that bit I’ve done wrong.

Thanks again!

In that case, just try the Date Format expression in the bindings of a template. Once it works properly, put it back into the location scheme.

I think I see what you did wrong.

$sys.item.getProperty returns a “Property” object, and you need a “Date” object. Try using $sys.item.getProperty(…).getDate() which returns a java.util.Calendar object.

Dave

Ah cool. Thanks!

I’ll let you know how I get on… :o)

That seems to have done it for me within the files themselves. I also have indices, where it’s not done it, which is odd.

To explain, here are links to a sample index and to a sample file. All the links on the index page still have the old (JanMar2008) style dates in the URLs, but all the links in the pages have the correct (20080111) style dates. (The links are to the unchanged production files, not the changed versions on our devserver.)

Is there something obvious I’m missing?