Arik, can't watch the video at the moment. Am I just completely off base then?
Almost completely.
Gordy, I have no idea what a controller is... will try to do some reading if I can find it.
The "Controller" is comprised of a bunch of files that have actionXXX methods. Think of those methods as individual PHP pages. They call in models & helpers for getting information, data writers for pushing it to the database. They prepare data, and when they're done, they send it off to the view.
It would be AWESOME if someone who is good at development in xenForo could just walk through, step by step, how to include a php file inside a template. All these referrals to documentation at php.net and around here are fine, but it is so piecemeal that it is difficult for someone who is not familiar with xenForo development to catch on. And I see that this is a very common request, yet none of the threads seem to get resolved with an answer on how to do it.
That's because you can't. Not directly, that is...
Here's the dirty version for what you're trying to do.
PHP:
<?php
class Asp_PhpIncludeTip_Plugin_Plugin
{
public static function includePhpFile($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
{
if($hookName == 'forum_list_sidebar')
{
ob_start();
require_once('php_include.php');
$contents .= ob_get_contents();
ob_end_clean();
}
}
}
Step by step:
0. Put your board into debug mode.
0.5. Create a new Plugin for this.
1. Create a new directory for your plugin. That directory defines your classname (it's how the autoloader works). So, in my case above, that directory is library/Asp/PhpIncludeTip/Plugin/ (library is already there...it's the parent folder for the XenForo folder)
2. Create a file within that directory for your plugin. That's the last part of the class name (the last Plugin in this case). So, as above, that file is going to be Plugin.php
So, Asp_PhpIncludeTip_Plugin_Plugin is translated to Asp/PhpIncludeTip/Plugin/Plugin.php
3. Within the Plugin.php file, set up your class as above, and then include a single method (public static function). At this point, go to the "Code Event Listeners" section of the admin and add a new code event listener (admin.php?code-event-listeners/add). Choose "template_hook". The section will expand to show you more information about the event listener. There's a section there for the "callback signature". Copy that and paste it between the parenthesis. The template hook signature looks like this:
PHP:
$hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template
4. Tell the method what to do. The PHP you type in here gets called on EVERY template hook that is parsed as the code is executed, so one of the first things you're going to want to do is tell it which hook to deal with.
PHP:
if($hookName == 'forum_list_sidebar')
5. Finish telling it what to do, then save out your work. Within the admin, finish setting up the event listener by telling it what class to execute, and what method to call within that class.
My "php include" file is saved in the same directory. If that's not where you want yours, you can throw it wherever. Just make sure you give it the right path (as you would have to regardless...)
Once you save everything out, you should be good to go.
It's Friday, and I'm in a good mood, so I've attached my (working for me!) example.