Page 1 of 1

explode Alternative

Posted: Tue Feb 08, 2011 3:12 pm
by reinhardl
Hallo,

if I use

Code: Select all

 {assign var=bildname value=".serendipityThumb.JPG"|explode:$entry.properties.ep_MimboImage} 
I will get this Message:
Smarty error: [in entries_single.tpl line 13]: [plugin] (secure mode) modifier 'explode' is not allowed (Smarty_Compiler.class.php, line 1934
is the an alternative funktion?

thanks

Re: explode Alternative

Posted: Tue Feb 08, 2011 3:51 pm
by garvinhicking
Hi!

You can disable the security mode in your template's config.inc.php.

However, the cleaner syntax would be to create your custom smarty modifier:

Code: Select all

<?php
function serendipity_smarty_bildname(&$var, $input) {
  $parts = explode(',', $input);
  foreach($parts AS $part) {
    $var .= $part . '.serendipityThumb.jpg';
  }
}

$serendipity['smarty']->register_modifier('serendipity_smarty_bildname', 'serendipity_smarty_bildname');
and in TPL:

Code: Select all

{$bildname|@serendipity_smarty_bildname:$entry.properties.ep_MimboImage}
(I don't know what you want to do do exactly, though, so you might need to use your own PHP function there :)

Regards,
Garvin