Hello,
Is it possible to extend a base template with another template in Smarty?
I know this is possible in Django using the {% entend %} tag. Is there an equivalent (or workaround) in Smarty?
Thanks
Hello,
Is it possible to extend a base template with another template in Smarty?
I know this is possible in Django using the {% entend %} tag. Is there an equivalent (or workaround) in Smarty?
Thanks
There is no build-in template inheritance in Smarty. But you can do similar thing with {include}
and {capture}
.
Your page template can look like:
{capture assign="context"}
<h2>Here is my page</h2>
{... some other smarty suff here ...}
{/capture}
{assign var="title" value="Just simple title text here"}
{include file="base.tpl"}
And base.tpl
can look like following:
<html>
<title>{$title}</title>
<body>
{$context}
</body>
</html>