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

How do I pass a param in xen:callback

Discussion in 'XenForo Development Discussions' started by AndyB, Jul 16, 2013.

  1. AndyB

    AndyB Well-Known Member

    In this thread:


    Mike said the following:

    "For advanced usage, you can also pass params to the callback via the params attribute (like in template hooks)."

    My question is how would I pass a param to my php script? Currently I placed this into my thread_view template:

    <xen:callback class="Andy_CalendarAdded_index" method="getHtml"></xen:callback>
  2. xf_phantom

    xf_phantom Well-Known Member

  3. AndyB

    AndyB Well-Known Member

    Hi xf_phantom,

    Thank you so much for your link. I've been looking at that and trying to make it work, but no success.

    What I would like to do is pass the thread_id to my php script.

    I was hoping something like this would work:

    <xen:callback class="Andy_CalendarAdded_index" method="getHtml" params="{$thread}"></xen:callback>

    my php script looks like this:

    class Andy_CalendarAdded {
        public static function 
    getHtml($content$params) {
  4. xf_phantom

    xf_phantom Well-Known Member

    have you tried params="{xen:array 'thread=$thread'} ?
    AndyB likes this.
  5. AndyB

    AndyB Well-Known Member

    Yes here's the code I added to my thread_view template:

    <xen:callback class="Andy_CalendarAdded_index" method="getHtml" params="{xen:array 'thread={$thread}'}"></xen:callback>
  6. AndyB

    AndyB Well-Known Member

    I'm making progress. Now just have to figure out how to extract the thread_id from the $param array.
  7. xf_phantom

    xf_phantom Well-Known Member

    Last edited: Jul 16, 2013
    AndyB likes this.
  8. AndyB

    AndyB Well-Known Member

    xf_phantom you're awesome!

    It ended being $params['thread']['thread_id']
    xf_phantom likes this.

Share This Page