Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

block.activestrip.php .... plz help ...

 
Post new topic   Reply to topic    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
Seppo
Smarty n00b


Joined: 27 May 2004
Posts: 2
Location: echo $World.Europe.Austria.Styria

PostPosted: Thu May 27, 2004 3:15 pm    Post subject: block.activestrip.php .... plz help ... Reply with quote

Exclamation i have the following problem ...

Code:
{if $stripCode}{strip}{/if}
... my code ...
{if $stripCode}{/strip}{/if}


i know, this doesn't work because Smarty need the {/strip} bevor the {/if} so i want to write my own strip Smile

Code:
{activestrip active=[true|false]}
... my code ...
{/activestrip}


Exclamation heres the bigger problem

i found the smarty-code for replacing this but i'm really worse in using regular expressions and i dont want to code it again

i want to use the buildin function {strip} of smarty ...


how i'm able to call the smarty-parse function inside my smarty_block_activestrip($params, $content, &$smarty)

[php:1:70bfca478a]
<?php

function smarty_block_activestrip($params, $content, &$smarty)
{
if (is_null($content)) {
return;
}
if ($params["active"] == true)
{
/* !!! return result of {strip}$content{/strip} !!! */
}
return $content;
}

?>
[/php:1:70bfca478a]

i hope someone is able to help me Cool
_________________
plz, don't consider my bad english Cool
i'm not married with a dictionary Rolling Eyes
Back to top
View user's profile Send private message Visit poster's website
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Thu May 27, 2004 7:49 pm    Post subject: Reply with quote

{strip} operates on the template source, not on the template's output. with block-plugins you can only operate on the output. so you cannot utilize the code {strip} uses inside an output-plugin.

a prefilter could do with parts of a template what {strip} does.

as an alternative there is an output-filter called "trimwhitespace". it does something similar to {strip} but works on the template's output.

you can use that filter inside a block-plugin like this:
[php:1:1df5c5eda1]<?php

function smarty_block_trimwhitespace($params, $content, &$smarty) {

if (isset($content)) {
/* $active defaults to true: */
$active = !isset($params['active']) || (bool)$params['active'];

if ($active) {
require_once $smarty->_get_plugin_filepath('outputfilter', 'trimwhitespace');
return smarty_outputfilter_trimwhitespace($content, $smarty);

} else {
return $content;

}
}
}

?>[/php:1:1df5c5eda1]

HTH
messju
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Seppo
Smarty n00b


Joined: 27 May 2004
Posts: 2
Location: echo $World.Europe.Austria.Styria

PostPosted: Fri May 28, 2004 1:15 pm    Post subject: Reply with quote

thx Smile

[php:1:6aabaa1d44]$res = smarty_outputfilter_trimwhitespace($content, $smarty);
return str_replace( array("\n","\r","\t"), array( "","",""), $res );[/php:1:6aabaa1d44]

jetzt hab ich das gleiche ergebnis Rolling Eyes
_________________
plz, don't consider my bad english Cool
i'm not married with a dictionary Rolling Eyes
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Plugins All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP