コード例 #1
0
ファイル: index.php プロジェクト: hkirsman/html-warrior
// pages/foo.tpl then pages/foo.php is also checked and included if
// available.
// write all the variables that you want to be added to the template to a
// variable called $params;
list($page_content, $page_variables) = $htmlwarrior->load_page();
// Set default template if not set from page template
if (!isset($page_variables['layout'])) {
    $htmlwarrior->layout = 'default';
} else {
    $htmlwarrior->layout = $page_variables['layout'];
}
// Get full layout path
$layout_path = $htmlwarrior->config['basepath'] . '/' . $htmlwarrior->runtime['site_dir'] . $htmlwarrior->config["path_templates_layouts"] . '/' . $htmlwarrior->layout . '.tpl';
// Get all variables indents so we can indent the content right
// We're after the $yield variable indent now
$variable_indents = get_indents_for_variables(file_get_contents($layout_path));
// set variables
// should these be added to layout template object (which we don't have yet)
foreach ($page_variables as $key => $var) {
    $smarty->assign($key, $var);
}
$yield = indent(remove_variables($page_content), $variable_indents['yield']);
$yield = ltrim($yield);
$smarty->assign('yield', $yield);
unset($yield);
// add access log; must be after frontpage so we don't log that
if ($htmlwarrior->config['log']) {
    add_access_log(array('site_dir' => $htmlwarrior->runtime['site_dir'], 'url' => $_SERVER['REQUEST_URI']));
}
//require_once('filelist.php');
ob_start('callback');
コード例 #2
0
ファイル: index.php プロジェクト: hkirsman/smartysh_test2
    $smartysh->logged_sufix = "";
    $smarty->assign("logged", false);
    $smartysh->logged = false;
}
$page_content = $smarty->fetch(get_page_template_path($smartysh->runtime["parsed_url"]["path"]));
if ($smartysh->config["build"]) {
    $template_filetime = filemtime(get_page_template_path($smartysh->runtime["parsed_url"]["path"]));
}
$page_variables = parse_variables($page_content);
if (!isset($page_variables["layout"])) {
    $smartysh->layout = "default";
} else {
    $smartysh->layout = $page_variables["layout"];
}
$layout_path = "layouts/" . $smartysh->layout . ".tpl";
$variable_indents = get_indents_for_variables(file_get_contents($smarty->template_dir . "/" . $layout_path));
if (isset($page_variables["title"])) {
    $smarty->assign("title", $page_variables["title"]);
} else {
    $smarty->assign("title", "");
}
if (isset($page_variables["custom1"])) {
    $smarty->assign("custom1", $page_variables["custom1"]);
} else {
    $smarty->assign("custom1", "");
}
$smarty->assign("yield", indent(remove_variables($page_content), $variable_indents["yield"]));
// add access log; must be after frontpage so we don't log that
if ($smartysh->config["log"]) {
    add_access_log(array("site_dir" => $smartysh->runtime["site_dir"], "url" => $_SERVER["REQUEST_URI"]));
}