Problém se šablonou @layout.latte (Cannot send header after HTTP headers have been sent)
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
- Hitny14
- Člen | 90
Ahoj,
dnes jsem narazil na chybu se kterou jsem se ještě nesetkal. Nahrál jsem
aplikaci na server a odstávám error 500. V laděnce jsem zjistil že se
jedná o chybu:
Cannot send header after HTTP headers have been sent (output started at
/temp/cache/latte/Base-templates-@layout.latte--03a45ab6bc.php:30)
Na řádce 30 v kompilované šabloně je pouze otevírací značka php
(<?php) viz:
<title><?php //řádek 30
if (isset($this->blockQueue["title"])) {
$this->renderBlock('title', $this->params, function ($s, $type) {
$_fi = new LR\FilterInfo($type);
return LR\Filters::convertTo($_fi, 'html', $this->filters->filterContent('striptags', $_fi, $s));
});
?> | <?php
}
?>example</title>
Zajímavé je pokud mám setDebugMode
na true
vše
funguje.
Nemáte někdo s touto chybou zkušenost? Děkuji moc krát za radu! :)
- Michal Hlávka
- Člen | 190
@CZechBoY v tomhle případě to ještě nevadí, tenhle kod neupravuje hlavičku.
@Hitny14 ještě někde nahore v kódu, budeš mít chybu. Nechceš poslat celou vyrenderovanou šablonu?
- Hitny14
- Člen | 90
@emptywall posílám celou šablonu
<?php
use Latte\Runtime as LR;
class Template03a45ab6bc extends Latte\Runtime\Template
{
public $blocks = [
'head' => 'blockHead',
'alert' => 'blockAlert',
'scripts' => 'blockScripts',
];
public $blockTypes = [
'head' => 'html',
'alert' => 'html',
'scripts' => 'html',
];
function main()
{
extract($this->params);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title><?php
if (isset($this->blockQueue["title"])) {
$this->renderBlock('title', $this->params, function ($s, $type) {
$_fi = new LR\FilterInfo($type);
return LR\Filters::convertTo($_fi, 'html', $this->filters->filterContent('striptags', $_fi, $s));
});
?> | <?php
}
?>example</title>
<link rel="stylesheet" href="<?php echo LR\Filters::escapeHtmlAttr(LR\Filters::safeUrl($basePath)) /* line 7 */ ?>/css/bootstrap.min.css">
<link rel="stylesheet" href="<?php echo LR\Filters::escapeHtmlAttr(LR\Filters::safeUrl($basePath)) /* line 8 */ ?>/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="<?php echo LR\Filters::escapeHtmlAttr(LR\Filters::safeUrl($basePath)) /* line 9 */ ?>/css/main.css">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="robots" content="noindex,nofollow">
<script>
function onJquery(method) {if (window.jQuery) {method();}else {setTimeout(function () {onJquery(method)}, 10);}}
</script>
<?php
if ($this->getParentName()) return get_defined_vars();
$this->renderBlock('head', get_defined_vars());
?>
</head>
<body>
<?php
if ($user->isLoggedIn()) {
?>
<nav class="navbar navbar-inverse">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="<?php echo LR\Filters::escapeHtmlAttr($this->global->uiControl->link("Homepage:")) ?>">example</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li <?php
if ($this->global->uiPresenter->isLinkCurrent("Homepage:default")) {
?>class="active"<?php
}
?>><a href="<?php echo LR\Filters::escapeHtmlAttr($this->global->uiControl->link("Homepage:default")) ?>">Hlavní stránka <span class="sr-only">(current)</span></a></li>
<li <?php
if ($this->global->uiPresenter->isLinkCurrent("Trainings:default")) {
?>class="active"<?php
}
?>><a href="<?php echo LR\Filters::escapeHtmlAttr($this->global->uiControl->link("Trainings:default")) ?>">Treninky</a></li>
<li><a href="#">Zapasy</a></li>
<li><a href="#">Brigády</a></li>
<li><a href="#">Statistiky účastí</a></li>
<li><a href="#">Přehled členů</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><?php
echo LR\Filters::escapeHtmlText($userInfo->name) /* line 49 */ ?> <?php echo LR\Filters::escapeHtmlText($userInfo->surname) /* line 49 */ ?><span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="<?php echo LR\Filters::escapeHtmlAttr($this->global->uiControl->link("EditProfile:")) ?>">Úprava profilu</a></li>
<?php
if ($user->isInRole('admin')) {
?><li><a href="<?php echo LR\Filters::escapeHtmlAttr($this->global->uiControl->link("EditUsers:")) ?>">Úprava uživatelů</a></li><?php
}
?>
<li role="separator" class="divider"></li>
<li><a href="<?php echo LR\Filters::escapeHtmlAttr($this->global->uiControl->link("logout!")) ?>"><i class="glyphicon glyphicon-off"></i> Odhlásit</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
<?php
$this->renderBlock('alert', get_defined_vars(), 'html');
$this->renderBlock('content', $this->params, 'html');
?>
</div>
<?php
}
else {
$this->renderBlock('content', $this->params, 'html');
}
?>
<script src="<?php echo LR\Filters::escapeHtmlAttr(LR\Filters::safeUrl($basePath)) /* line 70 */ ?>/js/jquery-3.1.0.min.js"></script>
<script src="<?php echo LR\Filters::escapeHtmlAttr(LR\Filters::safeUrl($basePath)) /* line 71 */ ?>/js/bootstrap.min.js"></script>
<script src="<?php echo LR\Filters::escapeHtmlAttr(LR\Filters::safeUrl($basePath)) /* line 72 */ ?>/js/netteForms.min.js"></script>
<?php
$this->renderBlock('scripts', get_defined_vars());
?>
</body>
</html>
<?php
return get_defined_vars();
}
function prepare()
{
extract($this->params);
if (isset($this->params['flash'])) trigger_error('Variable $flash overwritten in foreach on line 20');
Nette\Bridges\ApplicationLatte\UIRuntime::initialize($this, $this->parentName, $this->blocks);
}
function blockHead($_args)
{
}
function blockAlert($_args)
{
extract($_args);
$iterations = 0;
foreach ($flashes as $flash) {
?> <div class="alert alert-<?php echo LR\Filters::escapeHtmlAttr($flash->type) /* line 20 */ ?>"><?php
echo $flash->message /* line 20 */ ?></div>
<?php
$iterations++;
}
}
function blockScripts($_args)
{
}
}