1.0.3 How to add search by SUBTITLE

Discussion in 'General Support' started by Grinfeld, Jun 8, 2014.

  1. Grinfeld

    Grinfeld Member

    Joined:
    Apr 8, 2012
    Messages:
    66
    Likes Received:
    4
    Hello to all,

    What would the code be, to add in search.php and adsearch.php, to be able to search also by SUBTITLE?

    Thanks to all.
     
  2. Grinfeld

    Grinfeld Member

    Joined:
    Apr 8, 2012
    Messages:
    66
    Likes Received:
    4
    The code to add SUBTITLE and DESCRIPTION is:

    OK I found and archive by Pani 100 (thank you Pani) which provides the answer for another version, which I was able to adapt for 1.0.3

    Here is the code:

    Around line 57 in search.php

    Find:


    $query = "SELECT * FROM " . $DBPrefix . "auctions WHERE
    (title LIKE '%" . $term . "%' OR id = " . intval($term) . ")
    " . $catSQL . "
    AND closed = 0 AND suspended = 0 AND starts <= " . $NOW . " AND ends > " . $NOW;


    And Change for:


    $query = "SELECT * FROM " . $DBPrefix . "auctions WHERE
    (title LIKE '%" . $term . "%' OR subtitle LIKE '%" . $term . "%' OR description LIKE '%" . $term . "%' OR id = " . intval($term) . ")
    " . $catSQL . "
    AND closed = 0 AND suspended = 0 AND starts <= " . $NOW . " AND ends > " . $NOW;


    That's it. It works perfectly right. Once again thank you Pani100.

    Now, that is the code for search.php.

    I also want to add the capability, to search by subtitle, to advance search... but I am not sure about the addition I should made in the coding... Could some body help me with the code in adsearch.php??

    Thanks to all,
    Mario
     
    Last edited: Jun 9, 2014
  3. pani100

    pani100 Well-Known Member

    Joined:
    May 9, 2011
    Messages:
    2,327
    Likes Received:
    449
    Hi Mario,
    adsearch.php line 53 to 61 change to

    PHP:
    if (!empty($_SESSION['advs']['title']))
        {
            
    $wher .= '(';
            if (isset(
    $_SESSION['advs']['desc']))
            {
                
    $wher .= "(au.description like '%" $system->cleanvars($_SESSION['advs']['title']) . "%') OR ";
            }
            
    $wher .= "(au.title like '%" $system->cleanvars($_SESSION['advs']['title']) . "%'  OR au.subtitle LIKE '%" $system->cleanvars($_SESSION['advs']['title']) . "%' OR au.id = " intval($_SESSION['advs']['title']) . ")) AND ";
        }
     
    Grinfeld likes this.
  4. Grinfeld

    Grinfeld Member

    Joined:
    Apr 8, 2012
    Messages:
    66
    Likes Received:
    4
    Thank you Pani, works great!
    Kind regards,
    Mario
     
  5. pani100

    pani100 Well-Known Member

    Joined:
    May 9, 2011
    Messages:
    2,327
    Likes Received:
    449
    No problem Mario. Glad to help.
     

Share This Page