Search

This section describes how to create site search
  1. Install free search script 'sphinx'. http://sphinxsearch.com/
  2. Create sphinx source:
     source domain_name
     {
         type        = mysql
         sql_host    = localhost
         sql_user    = your_inxy_db_user    
         sql_pass    = your_inxy_db_pass
         sql_db        = your_inxy_db
    
         sql_query                = \
             SELECT rt.rotation_id, title, categories, tags, description, rt.content_type_id \
             FROM gals g JOIN rotation rt ON rt.gal_id = g.gal_id WHERE g.status_id = 3 AND g.disabled_sum = 0 AND rt.category_id IN (1,2,3)
    
         sql_attr_uint = content_type_id
    
         sql_query_info    = SELECT * FROM rotation WHERE rotation_id=$id
     }
    
  3. Create sphinx index
  4. Create config file inxy/var/config/sphinx.php
    <?php
    return array(
      "host" => "localhost",
      "port" => 3312,
      "index" => "sphinx_index_name"
    );
    ?>
    
  5. Create cron job for update search index
  6. Add search form to site:
    <form action="/">
    <input type="text" name="q">
    <input class="submit" type="submit"  value="Find" />
    </form>
    
  7. Create template site/search.php for seach results (<?=Inxy::req()->search?> outputs current search phrase)