|
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 |
damians Smarty n00b
Joined: 05 Feb 2007 Posts: 1
|
Posted: Mon Feb 05, 2007 7:28 pm Post subject: problem z funkcja blokowa |
|
|
ponizsza funkcja polega na zamianie slow. Jest to przyklad z ksiazki "Smarty- szablony w aplikacjach PHP" H.Hayder, J.P.Maia, L. Gheorghe. Jest on na stronie 193. Nie dziala prawidlowo. Dlaczego? Oto jej kod:
funkcja_blokowa.php
Code: |
<?php
require("Smarty.class.php");
$smarty = new Smarty;
$smarty->register_block("ban","check_words");
function check_words($params, $content, &$smarty, &$repeat)
{
$bad_words = explode(" ",$params['words']);
$words = explode(" ",$content);
for($i=0;$i<sizeof($words); $i++)
{
for($j=0; $j<sizeof($bad_words); $j++)
if( $words[$i] == $bad_words[$j])
{
$words[$i]='xxxx';
}
$output = implode(" ",$words);
return $output;
}
}
$smarty->display('register_block.tpl');
?>
|
register_block.tpl
Code: |
<html>
<head>
</head>
<body>
{ban words="abc xyz"}
Mysle, ze ta abc ma ladne xyz.
{/ban}
</body>
</html>
|
|
|
Back to top |
|
broda100 Smarty n00b
Joined: 20 Feb 2007 Posts: 0
|
Posted: Tue Feb 20, 2007 12:39 am Post subject: |
|
|
Na pierwszy rzut oka masz b??d w trzeciej linii:
$smarty = new Smarty;
powinno by?
$smarty = new Smarty(); |
|
Back to top |
|
broda100 Smarty n00b
Joined: 20 Feb 2007 Posts: 0
|
Posted: Tue Feb 20, 2007 12:40 am Post subject: |
|
|
Na pierwszy rzut oka masz b??d w trzeciej linii:
$smarty = new Smarty;
powinno by?
$smarty = new Smarty(); |
|
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
|