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

Is there a way to use objects in templates?

Discussion in 'XenForo Development Discussions' started by CJ.Wurtz, Dec 13, 2011.

  1. CJ.Wurtz

    CJ.Wurtz Member

    I've been searching for the better part of two hours now and haven't been able to find anything in either the forum or the code to answer this question.

    Is there a way to use a class object in a template? The only way I've figured to deal with it so far is either convert the object to an array when I pass the params to the controller, or using a template helper function to get the variable from the object. The latter I feel would probably have more overhead, but is cleaner. I figured I'd check if there was just some syntax I'm missing for the templates, or is just not supported by the template compiler?

  2. Mike

    Mike XenForo Developer Staff Member

    We only use arrays, though you could always implement the ArrayAccess interface for your class.
  3. CJ.Wurtz

    CJ.Wurtz Member

    Alright thanks for clarifying. This is one of those nagging questions I've had that I figured I'd finally figure out the answer to. I guess I'll continue the way I have, and perhaps convert some to use ArrayAccess where I can.

    Thanks again

Share This Page