Add Category Keyword Search (v. 2.83)

To add a search box in the storeadmin area to allow clients to search for categories with a specific keyword, you can use the following modification:

  1. Open the categories.php file in the /storeadmin/ folder.

  2. Find the code:

    // DISPLAY ORPHANS
  3. Just above that code, add the code:

    // MOD - SEARCH BY KEYWORD
    $cat_kw = str_replace('"', '"', $catkw);
    echo <<
    

    Search Categories By Keyword:

    END; if (!empty($catkw)) { $lowercat = strtolower($catkw); $catkresult = mysql_query("SELECT ID, Category FROM " . SB_DB_PREFIX . "_categories WHERE LOWER(Category) LIKE '%" .addslash_mq($lowercat) . "%' OR LOWER(Description) LIKE '%" .addslash_mq($lowercat) . "%' OR LOWER(Keywords) LIKE '%" .addslash_mq($lowercat) . "%'", $dblink); if (mysql_num_rows($catkresult) > 0) { echo "

    Categories with the keyword '$catkw'

    "; echo ""; while ($catkrow = mysql_fetch_array($catkresult)) { $ckid = $catkrow[ID]; echo ""; } echo "
    " . stripslashes($catkrow[Category]) . "Edit | Delete | Items | Reassign
    "; } } echo "
"; // END SEARCH BY KEYWORD
  • Save and reload the file.

  • At this point, your client will be able to search for categories with a particular keyword in the category name, description or keywords field.