Is there a way to use objects in templates?

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?

Thanks
 

Mike

XenForo developer
Staff member
We only use arrays, though you could always implement the ArrayAccess interface for your class.
 

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
 
Top