|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
kyhstynbai Smarty n00b
Joined: 25 Mar 2016 Posts: 2
|
Posted: Fri Mar 25, 2016 10:59 am Post subject: Smarty 3: template inheritance question |
|
|
Hi everyone.
I can't figure out how exactly template inheritance system works.
Let's say I have a layout like this:
layout.tpl
Code: |
<html>
<head>
<!--stuff-->
</head>
<body>
{block name=body}
{block name=pageheader}
{/block}
{block name=navbar}
<div class="nav-top">
<a href="#">main</a> |
<a href="#">tags</a> |
<a href="#">somestuff</a>
{/block}
{/block} {* closing body block *}
|
And a template file:
index.tpl
Code: |
{extends file="layout.tpl"}
{block name=body}
{block name=pageheader}
<div class="header">
<!--stuff-->
</div>
{/block}
{block name="navbar"}
<!-- this place must be inherited from layout! but it is not. -->
</div>
{/block} |
Maybe I am missing something with the ineritance system? How do I make the content of {navbar} block in layout.tpl render in all the child templates? |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Fri Mar 25, 2016 12:23 pm Post subject: |
|
|
Don't nest blocks.
At least don't nest them in the same template.
I think this is where your issue is from. |
|
Back to top |
|
kyhstynbai Smarty n00b
Joined: 25 Mar 2016 Posts: 2
|
Posted: Fri Mar 25, 2016 12:55 pm Post subject: |
|
|
Indeed.
Without nesting everything' pretty cool. Thanks. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|