|
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 |
vorapoap Smarty Rookie
Joined: 22 Dec 2009 Posts: 32
|
Posted: Fri Dec 17, 2010 4:51 pm Post subject: {block}creates 2sets of code in .tpl.php(1st w content=NULL) |
|
|
Here is the sample code.. I registerPlugin for block call json
Code: |
public function _block_json($params, $content) {
if ($content == NULL) return;
if ($params['assign']) {
$assign = $params['assign'];
} else {
list($assign) = array_keys($params);
}
$json = json_decode($content);
$this->assign($assign, $json);
}
|
In .tpl
Code: |
{json assign=groupForm}
[
{ "name":"group_name","type":"text" },
{ "name":"group_tag","type":"text" }
]
{/json}
|
There is one block call in above .tpl
However, in the final .tpl.php
There are 2 calls making to this _block_json function in run-time
The first one with $content = NULL
The second one with $content = actual content.
Code: |
<?php $_smarty_tpl->smarty->_tag_stack[] = array('json', array('assign'=>'groupForm')); $_block_repeat=true; $_smarty_tpl->smarty->registered_plugins['block']['json'][0][0]->_block_json(array('assign'=>'groupForm'), null, $_smarty_tpl, $_block_repeat);while ($_block_repeat) { ob_start();?>
[
{ "name":"group_name","type":"text" },
{ "name":"group_tag","type":"text" }
]
<?php $_block_content = ob_get_clean(); $_block_repeat=false; echo $_smarty_tpl->smarty->registered_plugins['block']['json'][0][0]->_block_json(array('assign'=>'groupForm'), $_block_content, $_smarty_tpl, $_block_repeat); } array_pop($_smarty_tpl->smarty->_tag_stack);?>
|
^^See the second line with null as a second parameter
$_smarty_tpl->smarty->registered_plugins['block']['json'][0][0]->_block_json(array('assign'=>'groupForm'), null, $_smarty_tpl, $_block_repeat);while ($_block_repeat) { ob_start();?> |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
|
Back to top |
|
vorapoap Smarty Rookie
Joined: 22 Dec 2009 Posts: 32
|
Posted: Mon Dec 20, 2010 7:15 pm Post subject: |
|
|
Oh. I kept being ignorance about this!
Thank you again! |
|
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
|