/** * Returns a singleton of a Twig_Environment object. * This is the handle that will be used to load templates * @return Twig_Environment */ private static function getTwig() { if (self::$twig == NULL) { require_once dirname(dirname(__FILE__)) . '/includes/config.php'; Twig_Autoloader::register(); $loader = new Twig_Loader_Filesystem(dirname(dirname(__FILE__)) . '/templates'); $params = array('debug' => TRUE, 'strict_variables' => TRUE, 'autoescape' => TRUE); // no cache if (TConfig::templateCachingEnabled()) { $params = array('debug' => TRUE, 'cache' => 'cache', 'strict_variables' => TRUE, 'autoescape' => TRUE); // no cache } self::$twig = new Twig_Environment($loader, $params); // no cache self::$twig->addExtension(new Twig_Extension_Debug()); } // add some useful globals available to all templates return self::$twig; }
<?php session_start(); require_once dirname(__FILE__) . '/_bootstrap.php'; TTwigHandler::display('educators', array('educators' => DBSmsToEducator::all(array('order' => 'trname asc', 'limit' => 30, 'offset' => 0)), 'sectiontitle' => 'Schools'));
<?php session_start(); require_once dirname(__FILE__) . '/_bootstrap.php'; TTwigHandler::display('index', array('schools' => DBSchool::all(array('order' => 'institution asc', 'limit' => 30, 'offset' => 0)), 'sectiontitle' => 'Schools'));