Mambot Поиска для Joomla 1.0.X

15.11.2009 07:07:32
Написание поискового мамбота для Joomla 1.0.X.
Для начала пример написания мамбота поиска:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
  defined( '_VALID_MOS' ) or die( 'Доступ запрещен' );

  $_MAMBOTS->registerFunction( 'onSearch', 'botSOMenuSRCH' );

  function botSOMenuSRCH( $text, $phrase='', $ordering='' )
  {
    global $database;

    $myItemid = '16';
    $sComName = 'com_somenu';
    $sTable = 'real_somenu_category';

    $botParams = new mosParameters( $mambot->params );
    $limit = $botParams->def( 'search_limit', 50 );

    $text = trim( $text );
    if ( $text == '' )
    {
      return array();
    }

    $sQuery1 = 'SELECT a.title AS title,'
      . "\n". ' a.title AS text,'
      . "\n". ' "" AS created,'
      . "\n". ' "" AS browsernav,'
      . "\n". ' "" AS section,'
      . "\n". ' CONCAT("index.php?option='.$sComName.'&Itemid='.$myItemid.'#", a.id) AS href'
      . "\n". ' FROM '.$sTable.' AS a'

      . "\n". " WHERE ( a.title LIKE '%$text%'"
//      . "\n". " OR a.text LIKE '%$text%'"
      . "\n". ' )'
//      . "\n". ' AND a.publish = 1'
      ;

    $database->setQuery( $sQuery1, 0, $limit );
//    $database->setQuery( $query1 .' UNION '. $query2, 0, $limit );
    $rows = $database->loadObjectList();

    return $rows;
  }
?>

Категории: CMS Joostina (Joomla 1.0.X), Joomla
Яндекс.Метрика