Beispiel #1
0
 /**
  * Render a sub element from within a view.
  * 
  * Views are not allowed to have business logic, but they can call upon
  * other generic, shared, views, called elements here.
  * 
  * @param string $elementName name of element to render
  * @param array $data optional data to pass to the element.
  * @return void
  * @throws Lvc_Exception
  * @author Anthony Bush
  **/
 protected function getElement($elementName, $data = array())
 {
     $view = Lvc_Config::getElementView($elementName, $data);
     if (!is_null($view)) {
         $view->setController($this->controller);
         return $view->getOutput();
     } else {
         error_log('Unable to render element "' . $elementName . '"');
         // throw new Lvc_Exception('Unable to render element "' . $elementName . '"');
     }
 }
Beispiel #2
0
<?php

// Derived Constants
// (NOTE that these are not needed by LightVC, but are usually useful in the app layer.)
define('APP_PATH', dirname(dirname(__FILE__)) . '/');
define('WWW_BASE_PATH', str_replace('index.php', '', $_SERVER['SCRIPT_NAME']));
define('WWW_CSS_PATH', WWW_BASE_PATH . 'css/');
define('WWW_JS_PATH', WWW_BASE_PATH . 'js/');
define('WWW_IMAGE_PATH', WWW_BASE_PATH . 'images/');

// Include and configure the LighVC framework
include_once(APP_PATH . 'modules/lightvc.php');
Lvc_Config::addControllerPath(APP_PATH . 'controllers/');
Lvc_Config::addControllerViewPath(APP_PATH . 'views/');
Lvc_Config::addLayoutViewPath(APP_PATH . 'views/layouts/');
Lvc_Config::addElementViewPath(APP_PATH . 'views/elements/');
Lvc_Config::setViewClassName('AppView');

// Lvc doesn't autoload the AppController, so we have to do it: (this also means we can put it anywhere)
include(APP_PATH . 'classes/AppController.class.php');
include(APP_PATH . 'classes/AppView.class.php');

// Load Routes
include(dirname(__FILE__) . '/routes.php');

?>