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

Template parameters not being passed

Discussion in 'XenForo Development Discussions' started by ceribik, Feb 3, 2012.

  1. ceribik

    ceribik Active Member

    I have a hook that adds my own template to "message_user_info". The template "message_user_info" is included in "message" as followed:
    Code:
        <xen:include template="message_user_info">
            <xen:map from="$message" to="$user" />
        </xen:include>
    
    For some reason, I'm unable to access the array "message" in my template (I'm passing the parameters properly). I've tried variations such as "user", "post", "message", etc to no avail.

    Any ideas?


    On another note, what does this do?
    Code:
    <xen:map from="$message" to="$user" />
    Thanks
     
  2. Bob

    Bob Well-Known Member

    Post your hook and your template. You might not be passing in the data correctly from the hook.
     
  3. ceribik

    ceribik Active Member

    I'm fairly certain it's fine. Here are the relevant bits:

    PHP:
        public static function templateHook($hookName, &$contents, array $hookParamsXenForo_Template_Abstract $template)
        {
            if (
    $hookName == "message_user_info_text")
            {
     
                
    //die(Zend_Debug::dump($template->getParam("message")))
                //die(print_r($template->getParams()));
                //die(Zend_Debug::dump($template->getParams()));;
                 
                
    $newContent $template->create("MyTemplateBlah"$template->getParams())->render();
    // note this code is incomplete
            
    }
        }
     
     
     
     
     
    From the templatethis is the variable that isn't working:
    {$message.user_id}
     
     
  4. Bob

    Bob Well-Known Member

    PHP:
    $contents .= $template->create("MyTemplateBlah"$template->getParams())->render();
     
  5. ceribik

    ceribik Active Member

    First of it, that's not what I'm trying to do. Secondly, it still doesn't work.
     
  6. Bob

    Bob Well-Known Member

    Works fine for me. and what are you trying to do
     
  7. ceribik

    ceribik Active Member

     
  8. ceribik

    ceribik Active Member

    I don't have any issue with my template not being inserted which is what you are assuming (due to failing to read my posts properly). The issue is with some of the parameters not being passed.
     
  9. Bob

    Bob Well-Known Member

    This is how I do mine... and they work just fine... sorry, just trying to help. I'll just shut the hell up from now on.

    PHP:
                    case 'account_alerts_extra':
                        
    $alertOptOuts = array('alertOptOuts' => $template->getParam('alertOptOuts'));
                           
                        
    $contents .= $template->create('xi_sportsbook_alert_preferences'$alertOptOuts);
                    break;
     
  10. ceribik

    ceribik Active Member

    Hmm. I managed to find the 'message' array parameter hiding in $hookParams, but that was missing the 'thread' array param, so using your idea, I made my own custom params array to pass into create()

    Thanks :)
     

Share This Page