Connection

In use the module to other modules in the file modules/module_name/module_name.inc.php described Module_name_inc.

Appeal to the module connection is through variable $this->diafan->_module_name. The first time the variable is instantiated class Module_name_inc.

Connection class inherits class Model described in the file includes/model.php. His description, refer to "Model".

The module model can appeal to a public function module is connected via a variable $this->inc.

For example, let's sell the news by its ID from anywhere in DIAFAN.CMS.

To do this, create in the folder modules/news/ file news.inc.php.

Example:

<?php
class News_inc extends Model
{
    
/**
    * Get news
    * @param int $id ID news
    * @return array or null in news not found
    */
    
public function get($id)
    {
        
$row = DB::query_fetch_array("SELECT [name], [anons] FROM {news} WHERE id=%d AND [act]='1' AND trash='0'", $id);

        return
$row;
    }
}

We verify our method in the file modules/shop/shop.model.php in the function get_result(), which returns the results generated in the shop model. Fill in:

Example:

$this->result["news"] = $this->diafan->_news->get(1);
print_r($this->result["news"]);
exit;

Turning on the catalog page, we should see our news item under the ID 1.