Virt
Новичок
Здравствуйте.
Имеется следующая архитектура:
Вся суть на скриншоте:
Имеется следующая архитектура:
PHP:
<?
class Controller {
public $modal;
public $view;
function __construct(){
$this->view = new View("application/view");
}
function action_index($url){}
}
class Controller_Main extends Controller{
function __construct(){
parent::__construct();
}
function action_index($arr){
$this->view->assign('v', new \lib\Order());
$this->view->generate("main.php");
}
}
class View {
protected $tpl_path;
protected static $vars;
public function __construct($tpl_path) {
$this->tpl_path = $tpl_path;
}
function generate($content_view = null, $template_view = null)
{
if(!empty(self::$vars))
extract(self::$vars);
if($template_view == null)
$template_view = "template_view.php";
include 'application/view/'.$template_view;
}
public function assign($var, $value) {
self::$vars[$var] = $value;
}
public function render($template_file) {
if(!empty(self::$vars))
extract(self::$vars);
include $this->tpl_path . '/' . $template_file;
}
}
//template_view.php
<!DOCTYPE html>
<html>
<head>
<meta content="text/html" charset="utf-8" />
<script src="/js/jquery-2.0.3.min.js"></script>
<link rel="stylesheet" href="/css/style.css">
<title></title>
</head>
<body>
include __DIR__.'/'.$content_view;
</body>
</html>
//main.php
$v

Последнее редактирование: