• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Pass array variable from template to template hook


Well-known member
What I need to do is pass a variable from a xen:foreach loop to the hook.
"post_edit" includes "attachment_editor" which includes "attachment_editor_attachment"
I've placed a hook within "attachment_editor_attachment"
<div class="controls">               
                <input type="button" value="{xen:phrase delete}" class="button smallButton AttachmentDeleter" data-href="{xen:link 'attachments/delete', $attachment}" />
                <xen:if is="{$attachment.thumbnailUrl}">
                    <input type="button" name="thumb" value="{xen:phrase thumbnail}" class="button smallButton AttachmentInserter" />
                    <input type="button" name="image" value="{xen:phrase full_image}" class="button smallButton AttachmentInserter" />
<xen:hook name="tags_editor_attachment" />
Now in the foreach variable "attachment" is available and I'd like to pass it to the hook. Within my templateHook function it is not in template _params so I'm assuming it's something that I need to set, but not sure how to pass that in.

If it helps the data I need is the specific attachment id that is currently in scope of the foreach loop.


Well-known member
Check that, figured it out just needed to pass in the variable as a hook param:
<xen:hook name="tags_editor_attachment"  params="{$attachment}" />