This article will discuss one way in which you may achieve a PHP include-like functionality in your template bits on your forum. It requires editing your ipsclass.php file, so make sure you back up everything that may be important to you before trying this.

Open ipclass.php

find around line 590:
Code: 
/*-------------------------------------------------------------------------*/
// INIT: Load cache
/*-------------------------------------------------------------------------*/
We will start our work right above this comment. I suggest you start with your own comment so that you understand what you did there later.

Code: 
/*-------------------------------------------------------------------------*/
// My Include function.
/*-------------------------------------------------------------------------*/
below that, paste
Code: 
function get_include_contents($filename) {
    if (is_file($filename)) {
        ob_start();
        include $filename;
        $contents = ob_get_contents();
        ob_end_clean();
        return $contents;
    }
    return false;
}

now go up to the top of the file and find
Code: 
* @package    InvisionPowerBoard
* @author   Matt Mecham
* @version    2.1
*/
class ipsclass {
right below type somthing like
Code: 
var $my_included_contents = '';
this will be the variable name you use in your template bit, name it what you want, but keep it consistent in the next steps. I will use "my_included_contents".

now find where the function initiate_ipsclass is. Keep following the file down until you find stuff that looks like:
Code: 
//-----------------------------------------
        // Max display name length
        //-----------------------------------------
        
        $this->vars['max_user_name_length'] = $this->vars['max_user_name_length'] ? $this->vars['max_user_name_length'] : 26;
right below that type
Code: 
//-----------------------------------------
        // Load my included contents
        //-----------------------------------------
        
        $this->my_included_contents = $this->get_include_contents('/path/to/file.php');
obviously replacing the variable with what you named it and the /path/to/file.php with the actual include path.

now in the template bit you can use {$this->ipsclass->my_included_contents} wherever you want the content.

Keep in mind, in the developer API they suggest never editing any of the core IPB files like this. So do it at your own risk!

This can be really expanded to you putting any sort of function you want in there, as long as it returns a variable or an array, you can use the same process. For my php includes, i just make the file i am including into a function and paste the function instead of actually including it.

This can be powerfull. This can be dangerous. Get it working on a test board first! Back up everything!
Lease Reviewed by Lease on . [TUT]Achieving a PHP Include in a template bit This article will discuss one way in which you may achieve a PHP include-like functionality in your template bits on your forum. It requires editing your ipsclass.php file, so make sure you back up everything that may be important to you before trying this. Open ipclass.php find around line 590: /*-------------------------------------------------------------------------*/ // INIT: Load cache /*-------------------------------------------------------------------------*/ We will start Rating: 5