For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > January 2006 > Re: [SMARTY] Creating custom loop block function









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [SMARTY] Creating custom loop block function
Kaloyan Tsvetkov

2006-01-09, 10:21 pm

Thank you, I will do that. Are you saying that I have to modify the &$repeat
parameter of the block function to make it loop?

What is the correct syntax for addressign smarty vars inside the
{cell}...{/cell} block ?

Here's my compiled template. Here's how I got the idea for reseting &$repeat
to true to keep the while() loop going.

--------
<?php /* Smarty version 2.6.10, created on 2005-12-23 12:04:10
compiled from proba.html */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins'
=> array(array('block', 'list', '
proba.html', 8, false),array('block', 'head', 'proba.html', 10,
false),array('block', 'column', 'proba.html', 11, false),array('block',
'rows', 'proba.html', 16, false),array('block', 'cell', 'proba.html', 17,
false),)), $this); ?>
<html>
<head>
<title>List Table Proba</title>

</head>
<body>

<?php $this->_tag_stack[] = array('list', array('data' =>
$this->_tpl_vars['rows']));
smarty_block_list($this->_tag_stack[count($this->_tag_stack)-1][1], null,
$this, $_block_repeat=true);while ($_block_repeat) { ob_start(); ?>

<?php $this->_tag_stack[] = array('head', array());
smarty_block_head($this->_tag_stack[count($this->_tag_stack)-1][1], null,
$this, $_block_repeat=true);while ($_block_repeat) { ob_start(); ?>
<?php $this->_tag_stack[] = array('column', array());
smarty_block_column($this->_tag_stack[count($this->_tag_stack)-1][1], null,
$this, $_block_repeat=true);while ($_block_repeat) { ob_start(); ?>1<?php
$_block_content = ob_get_contents(); ob_end_clean(); echo
smarty_block_column($this->_tag_stack[count($this->_tag_stack)-1][1],
$_block_content, $this, $_block_repeat=false); }
array_pop($this->_tag_stack); ?>
<?php $this->_tag_stack[] = array('column', array());
smarty_block_column($this->_tag_stack[count($this->_tag_stack)-1][1], null,
$this, $_block_repeat=true);while ($_block_repeat) { ob_start(); ?>2<?php
$_block_content = ob_get_contents(); ob_end_clean(); echo
smarty_block_column($this->_tag_stack[count($this->_tag_stack)-1][1],
$_block_content, $this, $_block_repeat=false); }
array_pop($this->_tag_stack); ?>
<?php $this->_tag_stack[] = array('column', array());
smarty_block_column($this->_tag_stack[count($this->_tag_stack)-1][1], null,
$this, $_block_repeat=true);while ($_block_repeat) { ob_start(); ?>3<?php
$_block_content = ob_get_contents(); ob_end_clean(); echo
smarty_block_column($this->_tag_stack[count($this->_tag_stack)-1][1],
$_block_content, $this, $_block_repeat=false); }
array_pop($this->_tag_stack); ?>
<?php $_block_content = ob_get_contents(); ob_end_clean(); echo
smarty_block_head($this->_tag_stack[count($this->_tag_stack)-1][1],
$_block_content, $this, $_block_repeat=false); }
array_pop($this->_tag_stack); ?>

<?php $this->_tag_stack[] = array('rows', array());
smarty_block_rows($this->_tag_stack[count($this->_tag_stack)-1][1], null,
$this, $_block_repeat=true);while ($_block_repeat) { ob_start(); ?>
<?php $this->_tag_stack[] = array('cell', array());
smarty_block_cell($this->_tag_stack[count($this->_tag_stack)-1][1], null,
$this, $_block_repeat=true);while ($_block_repeat) { ob_start(); ?>


0. <?php echo $this->_tpl_vars['SKU']; ?>
<?php echo $this->_tpl_vars['data']['SKU']; ?>


<?php $_block_content = ob_get_contents(); ob_end_clean(); echo
smarty_block_cell($this->_tag_stack[count($this->_tag_stack)-1][1],
$_block_content, $this, $_block_repeat=false); }
array_pop($this->_tag_stack); ?>
<?php $this->_tag_stack[] = array('cell', array());
smarty_block_cell($this->_tag_stack[count($this->_tag_stack)-1][1], null,
$this, $_block_repeat=true);while ($_block_repeat) { ob_start(); ?>

0. <?php echo $this->_tpl_vars['brand']; ?>
<?php echo $this->_tpl_vars['data']['brand']; ?>


<?php $_block_content = ob_get_contents(); ob_end_clean(); echo
smarty_block_cell($this->_tag_stack[count($this->_tag_stack)-1][1],
$_block_content, $this, $_block_repeat=false); }
array_pop($this->_tag_stack); ?>
<?php $this->_tag_stack[] = array('cell', array());
smarty_block_cell($this->_tag_stack[count($this->_tag_stack)-1][1], null,
$this, $_block_repeat=true);while ($_block_repeat) { ob_start(); ?>

<?php echo '
0. {$row_each.brand}
'; ?>


<?php $_block_content = ob_get_contents(); ob_end_clean(); echo
smarty_block_cell($this->_tag_stack[count($this->_tag_stack)-1][1],
$_block_content, $this, $_block_repeat=false); }
array_pop($this->_tag_stack); ?>
<?php $_block_content = ob_get_contents(); ob_end_clean(); echo
smarty_block_rows($this->_tag_stack[count($this->_tag_stack)-1][1],
$_block_content, $this, $_block_repeat=false); }
array_pop($this->_tag_stack); ?>
<?php $_block_content = ob_get_contents(); ob_end_clean(); echo
smarty_block_list($this->_tag_stack[count($this->_tag_stack)-1][1],
$_block_content, $this, $_block_repeat=false); }
array_pop($this->_tag_stack); ?>


</body>
</html>
--------

On 12/23/05, messju mohr <messju@lammfellpuschen.de> wrote:
>
> On Fri, Dec 23, 2005 at 01:27:50PM +0200, Kaloyan Tsvetkov wrote:
> working.
> values in
> even
> of
>
> wrong. reread http://smarty.php.net/manual/en/plu...k.functions.php
> and maybe reread your compiled template.
>
> version
> version
> Smarty
> data
> tag.
>
> wrong. see above.
>
>
>


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com