Re: Associative Array in a Primary Array Loop
| From: | Linus McCabe | Date: | Wed, 21 Nov 2001 07:19:29 +0000 |
| Subject: | Re: Associative Array in a Primary Array Loop | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-1994@lists.php.net to get a copy of this message | ||
Hi,
I'm trying to make a postfilter and I want to alter all the text in the template but leave the tags untouched.
I wouldnt have a problem if it wasnt for the <? ?> within html tags. I'm trying something like this:
...
$smarty->register_postfilter("testpf");
$smarty->display("index.tpl");
...
function testpf($tpl_source) {
$html = str_replace("\n", " ", $tpl_source);
preg_match_all( '/\<.*((\<\?).*(\?\>).*)*[^-=]\>/', $html, $tags );
preg_match_all( '/>.*?</', $html, $text );
$str="";
for ($i=0; $i< (count($tags[0]) > count($text[0]) ? count($tags[0]) : count($text[0])); $i++) { $str .= $tags[0][$i] . strtoupper(substr($text[0][$i], 1, -1));
}
$tpl_source = trim($str);
return $tpl_source;
}
but it doesent work very well. The postfilter gets into action, but also strtoupper parts of tags...
Did anyone else do a postfilter, or have a suggestion on how to alter text only ?
thanks
/linus