i'm watching a tutorials about CMS with OOP - PHP
on control page : (articles.php)
<?php
require_once('globals.php');
require_once(CONTROLLERS.'ArticlesController.php');
$articlesmodel = new ArticlesModel() ;
$catsmodel = new ArticlesCatsModel();
$controller = new ArticlesController($articlesmodel,$catsmodel);
$controller->show();
?>
globals.php:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
define('ROOT',dirname(__FILE__));
define('INC',ROOT.'/includes/');
define('CORE',INC.'/core/');
define('MODELS',INC.'/models/');
define('CONTROLLERS',INC.'/controllers/');
define('LIBS',INC.'/libs/');
/*
core files
*/
require_once(CORE.'config.php');
require_once(CORE.'mysql.class.php');
require_once(CORE.'raintpl.class.php');
require_once(CORE.'system.php');
System::Store('db',new mysql());
System::Store('tpl',new RainTPL()); //class RainTPL
?>
ArticlesController.php
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once(MODELS.'ArticlesModel.php');
require_once(MODELS.'ArticlesCatsModel.php');
class ArticlesController
{
private $articlesModel; //Articles Model Object
private $articlesCatsModel; //Articles Cat Model Object
//object of ArticlesModel class
public function __construct(ArticlesModel $articlesmodel,ArticlesCatsModel $catsmodel)
{
$this->articlesModel = $articlesmodel ;
$this->articlesCatsModel = $catsmodel ;
}
//add new cat
public function Add()
{
}
public function Show()
{
// array of articles from model :D
/*
he takes object from Articlesmodel.php
like private articles model
then he call the Get function
from ArticlesModel Class
*/
$articles = $this->articlesModel->Get();
$cats = $this->articlesCatsModel->Get();
//put them inside the template after getting them
System::Get('tpl')->assign('articles',$articles) ;
System::Get('tpl')->assign('cats',$cats) ;
// show them in the templatee
System::Get('tpl')->draw('blog');
}
}
The ArticlesCatsModel
ArticlesCatsModel includes/model
The ArticleModel The ArticleModel
While running articles.php
i get error
Warning: mkdir(): Permission denied in /var/www/html/cms/includes/core/raintpl.class.php on line 320
Fatal error: Uncaught exception 'RainTpl_NotFoundException' with message 'Template blog.html not found!' in /var/www/html/cms/includes/core/raintpl.class.php:270 Stack trace: #0 /var/www/html/cms/includes/core/raintpl.class.php(166): RainTPL->check_template('blog') #1 /var/www/html/cms/includes/controllers/ArticlesController.php(67): RainTPL->draw('blog.html') #2 /var/www/html/cms/articles.php(11): ArticlesController->Show() #3 {main} thrown in /var/www/html/cms/includes/core/raintpl.class.php on line 270
Aucun commentaire:
Enregistrer un commentaire