Check for existence of a string inside another string

Skinning and designing Serendipity (CSS, HTML, Smarty)
Post Reply
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Check for existence of a string inside another string

Post 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.
=Don=
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Check for existence of a string inside another string

Post 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}
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Check for existence of a string inside another string

Post by Timbalu »

Just to note: smarty request vars are lowercase e.g. $smarty.request
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Post Reply