|
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 |
tadeu_fo Smarty n00b
Joined: 21 Nov 2004 Posts: 4 Location: Aracaju, Brazil
|
Posted: Sun Nov 21, 2004 12:26 am Post subject: {section} next item |
|
|
Hi everybody I was trying to arrange an array as a table with 2 colums in such way that the dedigner could use without much programming.
But I could not find a way to do it without complex(using {math}) programming. So I made a section_next plugin that jumps next item on a section .
Here it is:
save it as function.section_next.php in your plugins folder.
Code: |
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* Smarty {section_next} function plugin
*
* Type: function<br>
* Name: section_next<br>
* Author: Tadeu Ferreira Oliveira
* Contact: tadeu_fo@yahoo.com.br
* Purpose: jump to the next element in a section
* @param array parameters
* @param Smarty
* @return null
*/
function smarty_function_section_next($params, &$smarty)
{
if (!isset($smarty->_sections[$params["name"]])){
$smarty->trigger_error("section_next: section '".$params["name"]."' not found");
return;
}
$smarty->_sections[$params["name"]]['index'] += $smarty->_sections[$params["name"]]['step'];
$smarty->_sections[$params["name"]]['iteration']++;
$smarty->_sections[$params["name"]]['rownum'] = $smarty->_sections[$params["name"]]['iteration'];
$smarty->_sections[$params["name"]]['index_prev'] = $smarty->_sections[$params["name"]]['index'] - $smarty->_sections[$params["name"]]['step'];
$smarty->_sections[$params["name"]]['index_next'] = $smarty->_sections[$params["name"]]['index'] + $smarty->_sections[$params["name"]]['step'];
$smarty->_sections[$params["name"]]['first'] = ($smarty->_sections[$params["name"]]['iteration'] == 1);
$smarty->_sections[$params["name"]]['last'] = ($smarty->_sections[$params["name"]]['iteration'] == $smarty->_sections[$params["name"]]['total']);
}
/* vim: set expandtab: */
?>
| [/list] |
|
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
|