User Rating: 2 / 5

Star ActiveStar ActiveStar InactiveStar InactiveStar Inactive
 

The View, as you might have guessed, is the 'V' in MVC. The View contains code that relates to presentation and presentation logic such as templating and caching. In the controller above we saw the show() method. This is the method that calls the view. The major component in the MindPHP.com MVC is the template class. The template.class.php file contains the class definition. Like the other classes, it has the registry available to it and also contains a __set() method in which template variables may be set and stored.

 

The show method is the engine room of the view. This is the method that loads up the template itseld, and makes the template variables available. Some larger MVC 's will implement a template language that adds a fhurther layer of abstraction from PHP. Added layers means added overhead. Here we stick with the speed of PHP within the template, yet all the logic stays outside. This makes it easy for HTML monkies to create websites without any need to learn PHP or a template language.

 

The template.class.php file looks like this:

<?php
Class Template {
private $registry;
private $vars = array();
function __construct($registry) {
$this->registry = $registry;
}
public function __set($index, $value)
{
$this->vars[$index] = $value;
}
function show($name) {
$path = __SITE_PATH . '/views' .'/' . $name . '.php';
if (file_exists($path) == false)
{
throw new Exception('Template not found in '. $path);
return false;
}
foreach ($this->vars as $key => $value)
{
$$key = $value;
}
include ($path);
}
}
?>

 

Recent Topics
Subject
Post Reply
Open
Recent
介绍Paytoread。插件只显示一些文本。
By wipaporn Wed 13 Feb 2019 3:17 pm Board Chinese Language - 简体中文
0
286
Wed 13 Feb 2019 3:17 pm By wipaporn
介绍插件MD水印(MD水印插件),自动水印插件
By wipaporn Wed 13 Feb 2019 3:15 pm Board Chinese Language - 简体中文
0
1038
Wed 13 Feb 2019 3:15 pm By wipaporn
Introducing Plugin MD Watermark, plug for automatic watermarking
By wipaporn Wed 13 Feb 2019 3:11 pm Board English Language
0
1336
Wed 13 Feb 2019 3:11 pm By wipaporn
Introducing PayToRead. The plugin shows only some text.
By wipaporn Wed 13 Feb 2019 3:08 pm Board English Language
0
1442
Wed 13 Feb 2019 3:08 pm By wipaporn
Introducing Component MFacebook to help with website membership registration with Facebook
By wipaporn Wed 13 Feb 2019 3:06 pm Board English Language
0
1409
Wed 13 Feb 2019 3:06 pm By wipaporn
Introducing Mrelated Article Specific Category Module (Storage browsing history).
By wipaporn Wed 13 Feb 2019 3:03 pm Board English Language
0
1561
Wed 13 Feb 2019 3:03 pm By wipaporn
Introducing Mod MDFiles Categories Module Bring Categories from MDFile.
By wipaporn Wed 13 Feb 2019 2:59 pm Board English Language
0
5311
Wed 13 Feb 2019 2:59 pm By wipaporn
Introducing the Mod MDFile recent module to show files from MDFile
By wipaporn Wed 13 Feb 2019 2:56 pm Board English Language
0
6578
Wed 13 Feb 2019 2:56 pm By wipaporn
Introducing MDFile Components for Joomla, helping to download document files on the website.
By wipaporn Wed 13 Feb 2019 2:49 pm Board English Language
3
2665
Wed 29 Apr 2020 11:49 am By mindphp
Features Review : Components MDFile membantu memuat turun fail dokumen di laman web.
By abdkode Wed 13 Feb 2019 2:37 pm Board Bahasa Language
0
988
Wed 13 Feb 2019 2:37 pm By abdkode
Features Review : Mod MDFile recent Module yang menunjukkan fail yang diupload
By abdkode Tue 12 Feb 2019 6:45 pm Board Bahasa Language
0
1335
Tue 12 Feb 2019 6:45 pm By abdkode
Features Review : Plugin MD Watermark memudahkan dalam meletakan tanda air atau watermark
By abdkode Tue 12 Feb 2019 4:20 pm Board Bahasa Language
0
690
Tue 12 Feb 2019 4:20 pm By abdkode
这个(Pace)是什么?
By Parichat Wed 06 Feb 2019 7:25 pm Board Chinese Language - 简体中文
0
669
Wed 06 Feb 2019 7:25 pm By Parichat
pace 가 뭐죠?
By Parichat Wed 06 Feb 2019 7:25 pm Board korean Language - 한국어
0
449
Wed 06 Feb 2019 7:25 pm By Parichat
Mindphp webboard 등록하는 방법
By wipaporn Wed 06 Feb 2019 6:12 pm Board korean Language - 한국어
0
96
Wed 06 Feb 2019 6:12 pm By wipaporn
minephp webboard 注册方法
By wipaporn Wed 06 Feb 2019 5:49 pm Board Chinese Language - 简体中文
0
172
Wed 06 Feb 2019 5:49 pm By wipaporn
How to register minephp webboard
By wipaporn Wed 06 Feb 2019 5:30 pm Board English Language
0
337
Wed 06 Feb 2019 5:30 pm By wipaporn
Let's get to know Korea
By wipaporn Mon 04 Feb 2019 8:04 pm Board korean Language - 한국어
0
511
Mon 04 Feb 2019 8:04 pm By wipaporn
Let's get to know China
By wipaporn Mon 04 Feb 2019 8:03 pm Board English Language
0
383
Mon 04 Feb 2019 8:03 pm By wipaporn
Apa itu Pace ? Masa yang diambil dalam 1 Kilometer atau 1 mile
By abdkode Mon 04 Feb 2019 7:31 pm Board Bahasa Language
0
666
Mon 04 Feb 2019 7:31 pm By abdkode