Code: Select all
{if $var|strpos:'blah'===0}
modifier 'strpos' not allowed by security setting <-- thrown in /home/content/html/bundled-libs/Smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php on line 17
Code: Select all
{if $var|strpos:'blah'===0}
Code: Select all
function is_in_string($string, $search) {
if (strpos($string, $search) === 0) {
return true;
}
return false;
}
$serendipity['smarty']->registerPlugin('modifier', 'is_in_string', 'is_in_string');
Code: Select all
{if $var|is_in_string:'blah'}
Does that support multiple values? like 'blah','food','drink' ?garvinhicking wrote: And then use
Code: Select all
{if $var|is_in_string:'blah'}
Code: Select all
function is_in_string($string, $search) {
foreach($search AS $idx => $searchval) {
if (strpos($string, $searchval) === 0) {
return true;
}
}
return false;
}
Code: Select all
function is_in_string($string, $search) {
$array = explode(',', $search);
foreach($array AS $idx => $searchval) {
if (strpos($string, $search) === 0) {
return true;
}
}
return false;
}
Code: Select all
{if $var|is_in_string:'<object,<embed,<iframe'}.
Code: Select all
{if $var|is_in_string:'<object' || $var|is_in_string:'<embed || $var|is_in_string:'<iframe'}
Code: Select all
function is_in_string($string, $search) {
$array = explode(',', $search);
foreach($array AS $idx => $searchval) {
if (strpos($string, $searchval) === 0) {
return true;
}
}
return false;
}
Code: Select all
function tag_from_link($tag) {
$ttag='';
if (strpos($tag,'title=')) {
$tit_s = strpos($tag,'title=')+7;
$tit_e = strpos($tag,'"',$tit_s+7);
$ttag = substr($tag,$tit_s,$tit_e-$tit_s);
}
return $ttag;
}
$serendipity['smarty']->registerPlugin('modifier', 'tag_from_link', 'tag_from_link');
It's likely that `$serendipity['smarty']` is still null when you run your code. serendipity_config_local.inc.php is executed very early, far before the moment the templates get interpreted. Put the code instead in the config.inc.php of your theme, there smarty will already be initialized.