1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Batch Update Threads: How do I search for keyword not *keyword*

Discussion in 'XenForo Questions and Support' started by OperaManiac, Oct 9, 2015.

  1. OperaManiac

    OperaManiac Well-Known Member

    I am trying to search for threads with just uber in title. But the search results are inclusive of words like Sauber and uberTwitter.

    Is there a way to restrict the search to exact keyword? I imagine modifying the core XenForo code would not be a good idea.

    Thanks!
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    Unfortunately, there is only a wildcard search available, so a code edit would be necessary - they are usually best avoided, but in this case as long as you make the change, do what you need to do, and then put the code back again, it shouldn't be a problem. You may even want to close the board temporarily as the particular code may be shared across other functions and therefore you don't want to necessarily affect the behaviour of those other functions.

    Open file library/XenForo/Model/Thread.php

    Find:
    PHP:
    $sqlConditions[] = 'thread.title LIKE ' XenForo_Db::quoteLike($conditions['title'], 'lr'$db);
    Replace:
    PHP:
    $sqlConditions[] = 'thread.title LIKE ' XenForo_Db::quoteLike($conditions['title'], ''$db);
    Once you're finished:

    Find:
    PHP:
    $sqlConditions[] = 'thread.title LIKE ' XenForo_Db::quoteLike($conditions['title'], ''$db);
    Replace:
    PHP:
    $sqlConditions[] = 'thread.title LIKE ' XenForo_Db::quoteLike($conditions['title'], 'lr'$db);
     
    OperaManiac likes this.
  3. OperaManiac

    OperaManiac Well-Known Member

    ah. thanks. this should come handy!
     
  4. Chris D

    Chris D XenForo Developer Staff Member

    Incidentally, the 'lr' in the original code translates to 'left/right' or, in terms of the wildcard, it would be '*keyword*'.

    'l' would be '*keyword'
    'r' would be 'keyword*'
    '' (as in the example above) would be 'keyword'
     
    Steve F and OperaManiac like this.

Share This Page