Accessing properties of the calling template

I’m in a snippet. I want to get to properties of the calling template. How?

The calling template isn’t really available to the snippet directly. Being able to get to the “calling” template is dependent on the version of Rhythmyx. In the more recent versions, by which I mean 6.5 and later. In those versions you can reference $sys.item.cloneParentItem, which will allow you to access the template of the parent.

Owen,

What Doug didn’t say is that it’s far easier to pass values from the page template to the snippet than it is to “reach back” into the page from the snippet.

If you place a value in a binding variable in the page, that value will be available in the snippet (and all subsequent snippets) unless it is overwritten by a subsequent binding (perhaps in the snippet).

You cannot access “system” bindings this way, as they are always overwritten when the new snippet is created, but if you place your own binding in a page(e.g. $mypagetype) you can access $mypagebinding in the snippet.

Of course, you need to make sure that you code your snippet template so that it still does something intelligent when the binding is not present, as it will not be there in preview mode.

I hope this helps

Dave

[QUOTE=dbenua;435]If you place a value in a binding variable in the page, that value will be available in the snippet (and all subsequent snippets) unless it is overwritten by a subsequent binding (perhaps in the snippet).

You cannot access “system” bindings this way, as they are always overwritten when the new snippet is created, but if you place your own binding in a page(e.g. $mypagetype) you can access $mypagebinding in the snippet.

Of course, you need to make sure that you code your snippet template so that it still does something intelligent when the binding is not present, as it will not be there in preview mode.

I hope this helps

Dave[/QUOTE]

Yeah, that is quite helpful, actually. Especially as I couldn’t get $sys.item.cloneParentItem to work ;o)

When you say it won’t be there in preview mode, I assume you mean previewing the snippet — it’ll still be there when previewing the page containing that snippet, right?

You’re correct. The value will be there when you preview the page but not when you preview the snippet by itself.

Cool, thanks. I’ll go see if I can get it all to work then ;o)

It didn’t work because it was the wrong name. It should be $sys.assemblyItem.cloneParentItem (or $sys.assemblyItem.getCloneParentItem())

As it happens, I got this sorted by setting a binding higher up the hierarchy of templates and snippets and this issue is now resolved.

Thanks for your help, both of you!