I have a layout template (below is an example but much less complex).
<body>
<header>
<nav></nav>
</header>
<div class="main">
<div class="left">
{include file=$content.left}
</div>
<div class="right">
{include file=$content.right}
</div>
</div>
<footer></footer>
{include file=$js_scripts}
</body>
The folder structure lets me have the layout file and then folders for the content. The problem with this is I need multiple template pages and once the content requires some inline code it will change. There are also pages that might not require the js_scripts which will result in a smarty error.
views/layout
layout_1.tpl
layout_2.tpl
views/pages/mypage
left_content.tpl
right_content.tpl
js_scripts.tpl
Is it possible to extract content from a page and assign it to a variable instead of including a file which may not even be needed. Im thinking something along the lines of this which will leave me with one page and the content together in once place
Layout.tpl
<body>
<header>
<nav></nav>
</header>
<div class="main">
<div class="left">
{$content.left}
</div>
<div class="right">
{$content.right}
</div>
</div>
<footer></footer>
{$js_scripts}
</body>
mypage.tpl
{extract variable $content.left}
<h1>Title</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptatem, tempore, quae, cum, consequatur quisquam totam facilis illo blanditiis porro in quidem repudiandae necessitatibus dolores eius quam sequi labore impedit id.</p>
{/extract}
{extract variable $content.right}
<ul>
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
</ul>
{/extract}
{extract variable $js_scripts}
<script src="js/jquery.js"></script>
<script>
$(document).ready(function() {
$('#id').click(function(){
// run code
});
});
</script>
{/extract}