PHP code example of firebrandhq / searchable-dataobjects
1. Go to this page and download the library: Download firebrandhq/searchable-dataobjects library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
firebrandhq / searchable-dataobjects example snippets
class DoNews extends DataObject implements SearchableLinkable {
private static $db = array(
'Title' => 'Varchar',
'Subtitle' => 'Varchar',
'News' => 'HTMLText',
'Date' => 'Date',
);
private static $has_one = array(
'Page' => 'PghNews'
);
private static $has_many = array(
'Asides' => 'Aside'
);
/**
* Filter array
* eg. array('Disabled' => 0);
* @return array
*/
public static function getSearchFilter() {
return array();
}
/**
* Fields that compose the Title
* eg. array('Title', 'Subtitle');
* @return array
*/
public function getTitleFields() {
return array('Title');
}
/**
* Fields that compose the Content
* eg. array('Teaser', 'Content');
* @return array
*/
public function getContentFields() {
return array('Subtitle', 'Content');
}
/**
* Parent objects that should be displayed in search results.
* @return SiteTree or SearchableLinkable
*/
public function getOwner() {
return $this;
}
/**
* Whatever this specific Searchable should be
class Aside extends DataObject implements Searchable {
private static $db = array(
'Header' => 'Varchar',
'Content' => 'HTMLText',
);
private static $has_one = array(
'DoNews' => 'DoNews'
);
/**
* Filter array
* eg. array('Disabled' => 0);
* @return array
*/
public static function getSearchFilter() {
return array();
}
/**
* Fields that compose the Title
* eg. array('Title', 'Subtitle');
* @return array
*/
public function getTitleFields() {
return array('Header');
}
/**
* Fields that compose the Content
* eg. array('Teaser', 'Content');
* @return array
*/
public function getContentFields() {
return array('Content');
}
/**
* Parent objects that should be displayed in search results.
* @return SiteTree or SearchableLinkable
*/
public function getOwner() {
return $this->DoNews;
}
/**
* Whatever this specific Searchable should be
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.