PHP Class Contao\Search

The class takes the HTML markup of a page, exctracts the content and writes it to the database (search index). It also provides a method to query the seach index, returning the matching entries. Usage: Search::indexPage($objPage->row()); $result = Search::searchFor('keyword'); while ($result->next()) { echo $result->url; }
显示文件 Open project: contao/core-bundle Class Usage Examples

Protected Properties

Property Type Description
$objInstance Search Object instance (Singleton)

Public Methods

Method Description
__clone ( ) Prevent cloning of the object (Singleton)
getInstance ( ) : Search Return the object instance (Singleton)
indexPage ( array $arrData ) : boolean Index a page
removeEntry ( string $strUrl ) Remove an entry from the search index
searchFor ( string $strKeywords, boolean $blnOrSearch = false, array $arrPid = [], integer $intRows, integer $intOffset, boolean $blnFuzzy = false ) : Result Search the index and return the result object

Method Details

__clone() final public method

Prevent cloning of the object (Singleton)
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. The Search class is now static.
final public __clone ( )

getInstance() public static method

Return the object instance (Singleton)
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. The Search class is now static.
public static getInstance ( ) : Search
return Search The object instance

indexPage() public static method

Index a page
public static indexPage ( array $arrData ) : boolean
$arrData array The data array
return boolean True if a new record was created

removeEntry() public static method

Remove an entry from the search index
public static removeEntry ( string $strUrl )
$strUrl string The URL to be removed

searchFor() public static method

Search the index and return the result object
public static searchFor ( string $strKeywords, boolean $blnOrSearch = false, array $arrPid = [], integer $intRows, integer $intOffset, boolean $blnFuzzy = false ) : Result
$strKeywords string The keyword string
$blnOrSearch boolean If true, the result can contain any keyword
$arrPid array An optional array of page IDs to limit the result to
$intRows integer An optional maximum number of result rows
$intOffset integer An optional result offset
$blnFuzzy boolean If true, the search will be fuzzy
return Contao\Database\Result The database result object

Property Details

$objInstance protected_oe static_oe property

Object instance (Singleton)
protected static Search,contao $objInstance
return Search