Генерация кода в переменную
-
- phpBB 1.0.0
- Сообщения: 9
- Стаж: 19 лет
Генерация кода в переменную
Сижу вот разбираюсь с phpbb-шными шаблонами и не пойму. А template.php умеет генерировать текст в переменную? Чтобы не сразу на страницу выводил, а в переменную генерил, которую потом можно было бы вставить куда угодно?
-
- phpBB 1.0.0
- Сообщения: 9
- Стаж: 19 лет
Уже сделал. Зря отписался.
ЗЫ: Тему можно закрыть.

Код: Выделить всё
function pparse($handle, $build_var = false)
{
if (!$this->loadfile($handle))
{
die("Template->pparse(): Couldn't load template file for handle $handle");
}
// actually compile the template now.
if (!isset($this->compiled_code[$handle]) || empty($this->compiled_code[$handle]))
{
// Actually compile the code now.
$this->compiled_code[$handle] = $this->compile($this->uncompiled_code[$handle]);
}
if($build_var === false) {
// Run the compiled code.
eval($this->compiled_code[$handle]);
return true;
} else {
ob_start();
eval($this->compiled_code[$handle]);
$eval = ob_get_contents();
ob_end_clean();
return $eval;
}
}