Skip to content

Bug when pushing to sections inside of fetched templates #305

@odahcam

Description

@odahcam

Imagine de following file structure.

One layout.phtml:

<html>
<head>
    <title>Document</title>

    <?php $this->section('custom-head') ?>
</head>
<body>
    <?php $this->content() ?>

    <?= $this->section('custom-footer', $this->fetch('footer-default')) ?>
</body>
</html>

One details.phtml page:

<?php $this->layout('layout.phtml') ?>

<h1>My Details page</h1>

<?php foreach ($items as $item) ?>
    <?= $this->fetch('item.phtml', ['item' => $item]) ?>
<?php endforeach ?>

One item.phtml page:

<?php $this->push('custom-head') ?>
<script>
    globalApiHelper.sendUserRenderedDetailsItem(itemPrice);
</script>
<?php $this->end() ?>

<h2>My item <?= $item->name ?></h1>

And finally

<?php
$renderedView = $platesEngine->render('details.phtml', ['items' => $items]);
echo $renderedView;

The push inside the fetched template (item.phtml) will never appear in the final $renderedView string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions