Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define sections inside inserted templates #81

Closed
oscarotero opened this issue Aug 13, 2015 · 1 comment
Closed

Define sections inside inserted templates #81

oscarotero opened this issue Aug 13, 2015 · 1 comment

Comments

@oscarotero
Copy link

I don't now if this is related with #47
I have partials to reuse some templates. For example:

<?php
//define the main layout
$this->layout('main');

//use some partials
if ($post) {
    $this->insert('post', ['post' => $post]);
}

//define some sections
$this->start('title');
echo 'This is a title';
$this->stop();
?>

In the "post" partial, I have something like this:

<article class="post">
    <h1><?= $post->title ?></h1>
    <?= $post->body ?>
</article>

<?php $this->start('extra-head') ?>
<style>
    .post {
        background: blue;
    }
</style>
<?php $this->stop(); ?>

And now, in the main template, the first section is printed but the one defined in the partial doesn't:

<html>
    <head>
        <title><?= $this->section('title') ?></title>
        <?= $this->section('extra-head') ?>
    </head>
    <body>
        <?= $this->section('content') ?>
    </body>
</html>
@ragboyjr
Copy link
Contributor

@oscarotero ya, this is the same issue as #47, i'll close this as it is a dup. Thanks though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants