Skip to content

Commit f07f95b

Browse files
committed
additional options on view rendering
Changed name of PAGE_URL constant to SITE_URL
1 parent aeb449e commit f07f95b

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

config/config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
define('DEVELOPMENT', true);
88

99
/** Stores site base url */
10-
define('PAGE_URL', '');
10+
define('SITE_URL', '');
1111

1212
/** Database host address */
1313
define('DB_HOST', '');

core/controller.class.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ abstract class Controller
1818
/** @var object Points to template engine class */
1919
protected $_template;
2020

21+
/** @var bool If true, page will be displayed */
22+
public $renderPage;
23+
2124
/** @var bool Render template without header and footer */
22-
public $withoutHeader;
25+
public $renderHeader;
2326

2427
/**
2528
* Constructor function for Controller class
@@ -33,7 +36,8 @@ function __construct($controller, $action)
3336
{
3437
global $inflect;
3538

36-
$this->withoutHeader = false;
39+
$this->renderPage = true;
40+
$this->renderHeader = true;
3741

3842
$this->_controller = ucfirst($controller);
3943
$this->_action = $action;
@@ -62,6 +66,8 @@ function set($name, $value)
6266
*/
6367
function __destruct()
6468
{
65-
$this->_template->render($this->withoutHeader);
69+
if ($this->renderPage) {
70+
$this->_template->render($this->renderHeader);
71+
}
6672
}
6773
}

core/template.class.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ function set($name, $value)
4343
/**
4444
* Renders template to user
4545
*
46-
* @param bool $noHeader If true, header and footer won't be rendered (i.e. for Ajax calls)
46+
* @param bool $renderHeader If false, header and footer will be omitted in rendering process
4747
*/
48-
function render($noHeader = false)
48+
function render($renderHeader = true)
4949
{
5050
extract($this->_variables);
5151

5252
// header
53-
if ($noHeader == false) {
53+
if ($renderHeader) {
5454
if (file_exists(ROOT . DS . 'application' . DS . 'views' . DS . $this->_controller . DS . 'header.php')) {
5555
include(ROOT . DS . 'application' . DS . 'views' . DS . $this->_controller . DS . 'header.php');
5656
} else {
@@ -62,7 +62,7 @@ function render($noHeader = false)
6262
include(ROOT . DS . 'application' . DS . 'views' . DS . $this->_controller . DS . $this->_action . '.php');
6363

6464
// fotter
65-
if (!$noHeader == false) {
65+
if ($renderHeader) {
6666
if (file_exists(ROOT . DS . 'application' . DS . 'views' . DS . $this->_controller . DS . 'footer.php')) {
6767
include(ROOT . DS . 'application' . DS . 'views' . DS . $this->_controller . DS . 'footer.php');
6868
} else {

0 commit comments

Comments
 (0)