Populating a template with data from the database

karll

Well-known member
I have an add-on with a template that is calling on PHP code. The PHP code fetches some data out of the database and returns this back in an array of a certain format, which the template is using to populate itself. (Well, something like that :))

What are the requirements on the PHP side of things to make this work? I.e. what kind of directory structure do I need? Any classes I need to extend?

Also, I was hoping to do this "properly" in terms of MVC considerations ...

(Background: I have a free add-on which appears to be unsupported, and want to make it work on XF1.2. I'm also hoping to learn something from the exercise.)
 
How are you calling the PHP code? Is there an add-on which fetches data and calls the proper template rendering classes?
 
How are you calling the PHP code?
Looks like it's called by the xen tags in the template? I see lots of xen tags like:
<xen:if is="{PHP expression here ...}">
and also
<xen:foreach loop="$add-on_name" value="$class_name" i="$limit">
etc.

Can't say I understand all of it - is there documentation handy anywhere that explains the various xen tags?

Is there an add-on which fetches data and calls the proper template rendering classes?
I think so. The fetching of data definitely works. There is a call to the responseView function (inherited from Xenforo_Controller?) somewhere in the code, which I'm guessing will render the populated template?
 
Back
Top Bottom