Page tree
Skip to end of metadata
Go to start of metadata

If the module is requested as display=modulename, the page 'page.modulename.php' will be INCLUDED (this has not changed).

However, a significant change that you should be aware of is that you should never do any processing of POST/GET in the page.whatever.php file.  The page is ONLY for displaying information, and should not contain any logic. A simple way to keep this distinction is to only write a stub for the page

// Pony Page.
// This gives you a shortcut to the 'class Ponies' defined in /var/www/html/admin/modules/ponies/Ponies.class.php
$pony = FreePBX::create()->Ponies();
// Do your display logic in the public function showPage in Ponies.
print $pony->showPage();

Use the BMO Hook 'doConfigPageInit($pagename)' to process any variables.  This is guaranteed to be called before anything else, including other hooking modules, on a page load. Note that you do not need to explicitly say that you want to hook yourself, this is implied in every module.

class Ponies extends FreePBX_Helpers implements BMO {
    public static $dbDefaults = array( 'bestpony' => 'Rainbow Dash' );
    // This is unneeded. You never need to hook yourself.
    public static function myConfigPageInits() { return array("ponies"); }

    public function showPage() {
        print "Best pony is ".$this->getConfig('bestpony'); // See the 'DB_Helper' documentation.
    public function doConfigPageInit() {
        // If you were doing a POST, you could catch it and..
        // $this->setConfig('bestpony', $_REQUEST['bestpony']);

Failing to create a 'public function doConfigPageInit()' will result in an error being printed at the top of the screen every time your module is loaded. 



  • No labels