|
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 |
Seppo Smarty n00b
Joined: 27 May 2004 Posts: 2 Location: echo $World.Europe.Austria.Styria
|
Posted: Thu May 27, 2004 3:15 pm Post subject: block.activestrip.php .... plz help ... |
|
|
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
Code: | {activestrip active=[true|false]}
... my code ...
{/activestrip} |
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 _________________ plz, don't consider my bad english
i'm not married with a dictionary |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Thu May 27, 2004 7:49 pm Post subject: |
|
|
{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 |
|
Seppo Smarty n00b
Joined: 27 May 2004 Posts: 2 Location: echo $World.Europe.Austria.Styria
|
Posted: Fri May 28, 2004 1:15 pm Post subject: |
|
|
thx
[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 _________________ plz, don't consider my bad english
i'm not married with a dictionary |
|
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
|