-
Notifications
You must be signed in to change notification settings - Fork 180
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
Add sections in inner most template #143
Comments
Change You don't need to echo the results of insert. |
Thank you, @rogerroelofs, but didn't work, echoing or not. I got the same result: the section content, added in a inner template, is lost. Looking in Template.php, I found:. if (isset($this->layoutName)) {
$layout = $this->engine->make($this->layoutName);
$layout->sections = array_merge($this->sections, array('content' => $content));
$content = $layout->render($this->layoutData);
} Here, the $this->layoutName is empty, when in inner level template, then the $sections aren't merged. Would be a bug? |
So are you not using a layout? I do this kind of thing all the time |
Once again, thank you @rogerroelofs
Master template excerpt: <!DOCTYPE html>
<html>
<head>
<?= $this->section('stylesheets') ?>
</head>
<body>
<?= $this->section('content') ?>
<?= $this->section('jsfiles') ?>
<?= $this->section('inlinejs') ?>
</body>
</html> Content template excerpt <?php $this->layout('default::layout', ['pageTitle' => 'Home']); ?>
<div class="ui vertical container segment">
...
</div>
<?php $this->insert("default::modal", [
'id' => 'form-filter',
'header' => 'Filtar Relação',
'content' => $content,
'actions' => $actions
]); ?> Modal template excerpt <div id="<?= isset($id) ? $id : 'default-modal' ?>" class="ui modal">
...
</div>
<?php $this->push('inlinejs') ?>
<script type="text/javascript">
var modalId = <?= isset($id) ? "'" . $id . "'" : 'default-modal' ?>;
$('#' + modalId).modal({
inverted: true,
onApprove: function () {
alert($('#' + modalId + ' form').serialize());
},
});
</script>
<?php $this->end(); ?> In this case, why do I need to write |
Sorry for the less than helpful reply. It appears that you can't use start() or push() in an inserted template without some kind of work around. See #47 In your case I would have done the js in a more generic way so you don't have to insert special script for each modal. Instead you can do something like this to operate on all modals of that type. $('.modal.some_class').modal({
inverted: true,
onApprove: function() {
alert($(this).find('form').serialize();
}
}); |
Closing in favor of #169. Thanks! |
I'm starting with Plates. I tried to add a content to a section in second level template and it was lost when the view was rendered. I "fixed" this passing the first level template ($this) as a variable to de next one ($parentTemplate).
list.phtml
modal.phtml
Is there a better way to do this? This is a limitation?
The text was updated successfully, but these errors were encountered: