1
slyss
How i can find a text ???
  • 2006/11/9 11:50

  • slyss

  • Quite a regular

  • Posts: 343

  • Since: 2006/1/26


in my template is possible to do this:

<{if $now_text [color=FF0000][b]it contains[/b][/color'word'}> 
....
....
....
<{/if}>


it contains is wrong....

Exists an operator to do this ?

thanks a lot
[size=x-large]2008 Xoops Book[/size]

2
Dave_L
Re: How i can find a text ???
  • 2006/11/9 15:27

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


This should work, although I haven't tested it:

<{if strpos($now_text, 'word') !== false}>

One possible problem: The Smarty manual mentions the === operator, but not the !== operator. But that may only be a mistake in the manual.

If you want the test to be case-insensitive, use stripos instead of strpos.

3
slyss
Re: How i can find a text ???
  • 2006/11/9 16:48

  • slyss

  • Quite a regular

  • Posts: 343

  • Since: 2006/1/26


yes yes yes yes yes

work great!!!!

thanks!!!!!! thanks a lot!!!

one question: where you have found this information? ... i have search into smarty site but i have found nothing...

thanks!!!!
[size=x-large]2008 Xoops Book[/size]

4
Dave_L
Re: How i can find a text ???
  • 2006/11/9 16:52

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


I'm glad it worked.

The Smarty manual says that you can use PHP functions in an <{if ...}> tag:
http://smarty.php.net/manual/en/language.function.if.php
Quote:
All PHP conditionals and functions are recognized, such as ||, or, &&, and, is_array(), etc.


The PHP function strpos is documented in the PHP manual: http://www.php.net/docs.php

Login

Who's Online

232 user(s) are online (170 user(s) are browsing Support Forums)


Members: 0


Guests: 232


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits