changing the slot template whilst generating the contents of a slot

Hi

I have an image content type with fields for the various size images used in different parts of the website. I also have a shared template which I like to use across Rhythmyx in different slots. The markup of the template is the same apart from the image slot contents

#slot_wrapped("ImageSlot" "<a href='$link' title='$displaytitle'>" "</a>")
<h3><a href="$link" title="$displaytitle">#field("displaytitle")</a></h3>
#field("description")

depending on where the template is used the template for the image slot will change. Is it possible to change this?

The end result is the user only having to insert an image once into the slot then Rhythmyx changing this images depending on where it’s used.

How do I pass the image template name from the parent slot to the slot above?

Cheers
James

James,

I’m not sure I follow all of this, so if I’m answering the wrong question, please clarify for me.

It sounds like what you want to do is to pass the “image template” name to the #slot_wrapped macro so that all items in the image slot come out with that same template.

In this case, it’s a simple matter of specifying in the $params of the slot something like “template=MyImageTemplate” (where MyImageTemplate is the name or ID of a template).

Unfortunately, you cannot do this with #slot_wrapped (or #slot_simple) because they don’t pass enough parameters. Both of these macros just call #slot with some extra empty parameters, so in your case the code would be:

#slot("ImageSlot" "" "<a href='$link' title='$displaytitle'>" "</a>" "" "template=MyImageTemplate")

The only difference between #slot and #slot_wrapped is the extra 3 parameters, 2 of which we leave as “” (empty).

Tell me if this helps

Dave

Hi Dave

I understand how to set the parameter of the template but can this value be set from the parent slot

eg

parent_slot

template containing ImageSlot

template containing ImageSlot

template containing ImageSlot

/parent_slot

This is so that users only have to aa the image into one slot and there only needs to be one shared template.

Cheers
James

You cannot directly set the slot template value, but you can pass “bindings” from the parent template to the snippet.

If you, for example, create a “$imageSize” binding and set it in the parent template, the snippet templates (even ones that are nested within other snippets) will see this value. You can use this value in a #if statement in the image snippets, or you can use it in a dispatch template to select the correct template for the desired image size.

One word of caution: there are actually 2 different maps of variables. Values set on the bindings tab are passed downward to each successive template. When Velocity runs, it makes a COPY of the variable map, and so values that you create with #set in a Velocity page don’t change the values in the bindings map that is inherited by the snippet assembly.

Dave