/** * 导入公用模板 * @param string $tpl * @param string $vars * @return string */ function __include__($tpl, $vars = '') { if ($vars) { \yunke\helpers\Template::Vars($vars); } echo \yunke\helpers\Template::run($tpl); }
/** * 模板渲染,简化 * @param bool $layout 是否启用布局,默认启用 * @param string $view 模板名 * @void */ public function display($layout = true, $view = '') { //把所有的变量指给模板 add by sglz $this->vars = array_merge($this->vars, ['action' => $this->action->id]); $this->assign('urlparams', $_GET); $tplData = $this->vars; if (isset($_SERVER['HTTP_USER_AGENT'])) { $isAndroid = stripos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false ? 1 : 0; $tplData = array_merge($tplData, ['isAndroid' => $isAndroid]); } $this->assign('tpldata', $tplData); $this->setTheme(); //设置主题 \yunke\helpers\Assets::register($this->module->id, $this->theme); //注册模板助手信息 \yunke\helpers\Template::current(['path' => $this->module->id . '/views/' . $this->id]); \yunke\helpers\Template::Vars($this->vars); if (empty($view)) { $view = $this->action->id; } $view = str_replace(' ', '', ucwords(str_replace('-', ' ', $view))); echo $this->fetch($view, $layout); }