Current Slot Template

Hi,

Fingers crossed this has a simple answer.

In a velocity template, having called #initslot, and then opened up a #foreach loop to interate through the slots, is it then possible to pull out the template with which that slot was linked to the content item. To be a bit more specific:

I’ve got

#initslot(“Image_Link” “”)
#if($sys.currentslot.relresults.size() > 0)
#foreach($relresult in $sys.currentslot.relresults)

$relresult

#end
#end

What I’m thinking is that there must be some sort of built in function I can execute on $relresult to get the template. I’ve had a look through the docs we have, but can’t find anything.

Big thanks for any help.

$relresult.template returns the template object. You can also use expressions like $relresult.template.name or $relresult.template.label.

Many thanks, that seems to work a treat.

It’s really, so I’m guessing that it’s in some of the documentation somewhere, but i couldn’t see it in those that we have here.

thanks again.

You have to look in the JavaDoc, which is found on your server. Look at

<server>/Rhythmyx/Docs/Rhythmyx/Javadocs/index.html

$relresult is an object of type IPSAssemblyResult. You will see that this interface has a “getTemplate()” method. In Velocity, $relresult.getTemplate() is exactly that same as $relresult.template.

I realize that Javadoc is a bit hard for non-programmers to read, but there’s a wealth of information about how to access Objects within the server in those pages.

The PSO toolkit has it’s own Javadoc which is useful if you use methods from the toolkit this is located at:

<server>/Rhythmyx/Docs/Rhythmyx/PSOToolkit/index.html

thanks for that, I shall take a look at it.

Dave,

I am a programmer and I have been using Java for over 10 years. The problem is making the conversion from java to Velocity. Is there a magic decoder ring somewhere that translates the java method getTemplate() into the velocity shortcut .template? I ask because this information is not provided in any documentation (in a concise or complete manner) or the Java Docs.

John

The “magic decoder ring” is in the Velocity user documentation. See http://velocity.apache.org/engine/releases/velocity-1.6.2/user-guide.html#properties

The whole “methods as properties” convention comes from the JSP Expression Language, which formalized this concept around Java Beans. Since all beans which have a “foo” property will implement the method getFoo(), the reference to the property just calls the getter method.

Velocity, JEXL and other such languages just follow suit here. This certainly could be clearer: we initially decided that trying to re-write the Velocity documentation would amount to “boiling the ocean”. Perhaps we were wrong and there needs to be better documentation from the Velocity end.

Dave

Dave,

I appreciate the explanation. This helps a great deal. I understand the desire to not boil the ocean.

Thanks.

John