Announcement

Collapse
No announcement yet.

Conditional based on a string containing another string

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Conditional based on a string containing another string

    I'm trying to write a conditional that compares two strings. If string one is contained in string 2, the conditional is true.

    string1 = 'cat'
    string2 = 'cat, dog, mouse'

    <if condition="$string2 == $string1">
    This is stuff only a cat member will see...
    </if>
    How can I modify the above code to be CONTAINS instead of IS?

    Thanks!

  • #2
    Unfortunately that requires string functions which are not allowed in template conditionals. The following functions are allowed in template conditional expressions:

    in_array() is_array() is_numeric() isset() empty() defined() array() can_moderate() can_moderate_calendar() exec_switch_bg() is_browser() is_member_of()

    The function you need is strstr().

    What exactly do you want to do? You might be able to use the phpinclude_start template for your application.

    Comment


    • #3
      I have same problem.

      I have a variable $referrer which is the url of the referring page.

      I want to make a conditional: if $referrer contains the string "xyz" then

      Comment


      • #4
        Sorry, there is no function to do this. This requires modifying the code. We cannot officially support code modifications or forums running modified code, however you can try searching or asking for help with this over at www.vbulletin.org.
        Kerry-Anne :)

        Twitter Blog

        www.peterska2.com www.worldnewszone.com www.popularusenetgroups.com www.superclickers.co.uk www.forumsforchrist.com www.browsergameplanet.com

        Comment

        widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
        Working...
        X