What’s the syntax to generate publish location within a template?
However, I would like to set the call to always use publish context, even in preview.
Not sure if this is supported, because I don’t see such method in the javadoc for PSLocationUtils.
Clone the assembly item, and then call
This will guarantee that the assembly context is the publish context. You can then get the location in the usual way.
Apologies for bringing up an old thread, but this is exactly what I’m trying to do, and it doesn’t seem to be working. I’m hoping I’m missing something simple.
In version 6.5.2, in my template, I have the following:
#set($clonedItem = $sys.assemblyItem.clone())
#set($ret = $clonedItem.setParameterValue(“sys_context”,“1”))
#set($path = $rx.location.generate($clonedItem,“gs_txtGenericPage”))
With those lines, $path ends up containing an empty string. If I take out the setParameterValue line, then $path contains the Preview context location. I’ve also tried doing this with the clone created in a Binding instead with the same result. I do have a location scheme defined for the content type with the template listed above.
Am I missing a step here? Is there a good way to find out what’s going wrong with the call to $rx.location.generate?
If this is explained somewhere in the PDF documentation or help files or other documentation, feel free to just point me at that. I’m just not even sure what to look up to guide me further. Thanks.
sys_context value needs to match the actual context ID used for your site (preview or publish). Is it really “1”, that is used in your assembly URL?
Thanks. Yes, the location schemes are set up under the Publish(1) context. I could try creating a different context I suppose and using that, but all my location schemes are currently set up under that same context, so I’d rather not have to move things unless absolutely necessary.
If the correct context is used in the contentlists, and the location schemes are correct, and yet you still get EMPTY $path, then you should be getting publishing errors, because that’s the path that the publishing engine uses to publish. So, are you getting publishing errors?