|
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 |
hegem0n Smarty Rookie
Joined: 13 Feb 2010 Posts: 9
|
Posted: Sat Feb 13, 2010 2:33 pm Post subject: |
|
|
Hi!
Its so great to have the {block} feature. I was very excited to see that in the README. Im also glad to see the nesting fuctionality, as I got to this forum seeking this one. It's good to know {block} s going into direction I would like it to go.
Speaking of directions, here is a feature you might consider, namely an option to separate block definition from block usage.
Here's an example:
html.tpl:
{block name="header"}{/block}
{block name="content"}[content placeholder]{/block}
page.tpl:
{block name="content"}Here is a content{/block}
So far so good: "extends:html.tpl|page.tpl"
Now consider this template:
custom-layout.tpl:
{fill-block name="content"}
*** begin pretty border ***
{redefine-block name="content"}[content placeholder]{/redefine-block}
*** end pretty border ***
{/fill-block}
Now I'd like to be able to invoke:
* old one: "extends:html.tpl|page.tpl"
* new one: "extends:html.tpl|custom-layout.tpl|page.tpl"
Or even more chaining: "extends:html.tpl|custom-layout.tpl|add-sidebar.tpl|page.tpl", and so on.
From what I understand, it's not possible to do that now.
And another powerful option, is to be able to assign Data object to the linked templates separately, which would make this breadcrumb implementation possible:
item.tpl:
{block name="breadcrumbs" append} > {$title}{/block}
And now invoke 'extends:item.tpl[title="Root"]|item.tpl[title="Child"]|item.tpl[title="Subchild"]'.
I know it's easy only to ask for features, but I hope you will see that adding them, espetialy the first one, would be a great value for Smary users, which I am for years.
Also, regarding the first feature, I would like you to look into the Macro Extension for TAL temaplates, METAL. Since we're not reinventing the wheel here, it might be goot to look at the "competition". I'm sorry if the the above mentioned feature were discussed/rejected before.
Best regards,
Pawel |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sun Feb 14, 2010 9:40 am Post subject: |
|
|
This is the answer to the last entry of zimboden
Sorry the functionallity of template inheritance is to replace the source code of block tags in the parent with the sourecode code of corresponding blocks defined in the child. The block content of child template gets not parsed or executed itself. Parsing and execution does only take place on the resulting merged code of the parent.
Remember only the parent is defining the order if which the blocks shall be executed. Blocks in childs can contain code which is depending on results of other blocks which are not know when the child is being processed.
This definition of template inheritance is not just Smarty's. |
|
Back to top |
|
hegem0n Smarty Rookie
Joined: 13 Feb 2010 Posts: 9
|
Posted: Sun Feb 14, 2010 4:39 pm Post subject: |
|
|
So that would make the second feature a bit harder to make (you would have to isolate the context of parts of the templates, potentially by using closures).
The first feature, however, is perfectly possible, right?
Pawel. |
|
Back to top |
|
zimboden Smarty Rookie
Joined: 10 Feb 2010 Posts: 19
|
Posted: Mon Feb 15, 2010 4:56 pm Post subject: |
|
|
Hegemon,
I started a new thread regarding your {block} comments, so as not to extend this one. See "New {block} tag uses". Regards. |
|
Back to top |
|
zimboden Smarty Rookie
Joined: 10 Feb 2010 Posts: 19
|
Posted: Mon Feb 15, 2010 9:09 pm Post subject: |
|
|
Hegemon,
I just now posted that reply. It takes me a while to make a reasonable clear response. It's in the new thread {block} tag and their uses in the Smarty 3 forum. |
|
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
|