Page 1 of 1

Check for existence of a string inside another string

Posted: Mon Nov 26, 2012 8:47 pm
by Don Chambers
I need to determine if a particular string exists inside another string... these fail due to a security restriction:

Code: Select all

{if $string|strstr:"foo"} 
{if $string|stripos:"foo"}
{if preg_match("foo", $string)} 
I am not against using a config.inc.php template-specific function, but I am already having difficulty with something similar in the 2.0 branch.

Re: Check for existence of a string inside another string

Posted: Sun Dec 02, 2012 5:36 pm
by garvinhicking
Hi!

Code: Select all

{if $smarty.request.serendipity.adminModule == 'entries'}
...here you output anything you need because you're in the "Entries" section...
{/if}

{if $smarty.request.serendipity.adminModule == 'plugins' OR $smarty.request.serendipity.adminModule == 'templates'}
...here you output anything you need because you're in the "Appearance" section...
{/if}

Re: Check for existence of a string inside another string

Posted: Sun Dec 02, 2012 6:03 pm
by Timbalu
Just to note: smarty request vars are lowercase e.g. $smarty.request