Pass array variable from template to template hook

simbolo

Well-known member
What I need to do is pass a variable from a xen:foreach loop to the hook.
Example:
"post_edit" includes "attachment_editor" which includes "attachment_editor_attachment"
I've placed a hook within "attachment_editor_attachment"
PHP:
<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:if>
            </div>
<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.
 
Check that, figured it out just needed to pass in the variable as a hook param:
PHP:
<xen:hook name="tags_editor_attachment"  params="{$attachment}" />
 
Better:
PHP:
<xen:hook name="buzztags_editor_attachment"  params="{xen:array 'attachment={$attachment}'}" />
 
Top Bottom