looping plugin

From: Date: Sat, 03 May 2003 05:30:30 +0000
Subject: looping plugin
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-9458@lists.php.net to get a copy of this message
Hi there, I know there is an additional looping paramater to the block plugin in CVS, but i'm not sure it can do what I need it to do. What I need is a custom block function that acts like a section. the end result of this: ( assuming my custom block function is called block.events.php ) {events month="jan"} <h1>{$events[n].name}</h1> <p>{$events[n].description} <br>{$events[n].date|date_format:"%D"} {/events} would be <h1>My first event</h1> <p>Description <br>Sunday <h1>My second event</h1> <p>Description <br>Thusday I tried making the following plugin ( smarty 2.5.0 ) function smarty_block_entries($params, $content, &$smarty) {
    global $db;
    if (!isset($content)) { /* first call */
        if (!isset($params['var'])) $varname = "entries";
if(isset($params['month'] $adsql = " where month='".$params['month']."'"; $newcontent = $smarty->left_delimiter.'section name=n loop=$'.$varname.$smarty->right_delimiter; $results = $db->get_results("select * from entries $adsql"); $smarty->assign($varname,$results); return $newcontent;
    } else {
    	return $content.$smarty->left_delimiter.'/section'.$smarty->right_delimiter;
    }
} But it doesn't work ( smarty doesn't seem to parse the returned smarty code. I am looking for a way to impliment this custom block plugin. Best Regards Eaden McKee

« previous php.smarty.general (#9458) next »