{"id":20816068,"url":"https://github.com/arillo/silverstripe-simple-search","last_synced_at":"2026-03-14T21:04:49.714Z","repository":{"id":62486992,"uuid":"264209477","full_name":"arillo/silverstripe-simple-search","owner":"arillo","description":null,"archived":false,"fork":false,"pushed_at":"2022-03-01T12:09:55.000Z","size":34,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-18T12:07:17.334Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arillo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-15T14:05:39.000Z","updated_at":"2022-03-01T12:09:32.000Z","dependencies_parsed_at":"2022-11-02T10:46:42.437Z","dependency_job_id":null,"html_url":"https://github.com/arillo/silverstripe-simple-search","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arillo%2Fsilverstripe-simple-search","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arillo%2Fsilverstripe-simple-search/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arillo%2Fsilverstripe-simple-search/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arillo%2Fsilverstripe-simple-search/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arillo","download_url":"https://codeload.github.com/arillo/silverstripe-simple-search/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243163892,"owners_count":20246598,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-17T21:27:53.225Z","updated_at":"2025-12-24T21:50:51.091Z","avatar_url":"https://github.com/arillo.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# arillo/silverstripe-simple-search\n\nAdds simple site search to your project.\n\n### Requirements\n\nSilverStripe CMS ^4.0\n\n### Simple page example\n\n```php\n\u003c?php\nuse SilverStripe\\CMS\\Model\\SiteTree;\nuse Arillo\\SimpleSearch\\ISearchIndexable;\nuse Arillo\\SimpleSearch\\SearchableExtension;\nuse Arillo\\SimpleSearch\\SearchIndexEntry;\n\nclass Page extends SiteTree implements ISearchIndexable // you need to implement this interface\n{\n    private static $extensions = [\n        // adds after write/delete hooks to re-index this record\n        SearchableExtension::class,\n    ];\n\n    // add interface function, it should return the string you want to add to your search index.\n    public function forSearchIndex()\n    {\n        $contents = [\n            $this-\u003eTitle,\n            $this-\u003eobj('Content')\n                -\u003esetProcessShortcodes(true)\n                -\u003eRAW()\n        ];\n\n        $string = implode($contents, ' ');\n        return $string ? SearchIndexEntry::sanitize_string($string) : null;\n    }\n}\n\n```\n\n### (Re-)Build the search index\n\n```\nphp vendor/silverstripe/framework/cli-script.php dev/tasks/Arillo-SimpleSearch-BuildIndexTask\n```\n\n\n### Integrate with Fluent\n\nAdd `search.yml` to your config:\n\n```\nArillo\\SimpleSearch\\SearchIndexEntry:\n  extensions:\n    - TractorCow\\Fluent\\Extension\\FluentExtension\n  translate:\n    - Title\n    - SearchableText\n```\n\n### Integrate with arillo/elements\n\nAdd the extension, so update / publish elements will trigger an reindex of the holder page.\n\n```yaml\nArillo\\Elements\\ElementBase:\n  extensions:\n    - Arillo\\SimpleSearch\\ElementDataExtension\n```\n\nImplement `ISearchIndexable` e.g. like this:\n\n```php\n\u003c?php\nuse SilverStripe\\CMS\\Model\\SiteTree;\nuse SilverStripe\\View\\SSViewer;\nuse SilverStripe\\Core\\Config\\Config;\nuse Arillo\\SimpleSearch\\ISearchIndexable;\nuse Arillo\\SimpleSearch\\SearchableExtension;\nuse Arillo\\SimpleSearch\\SearchIndexEntry;\nuse Arillo\\Elements\\ElementsExtension;\n\nclass Page extends SiteTree implements ISearchIndexable // you need to implement this interface\n{\n\tconst SECTIONS = 'Sections';\n\n    private static $extensions = [\n        // adds after write/delete hooks to re-index this record\n        SearchableExtension::class,\n    ];\n\n    // add interface function, it should return the string you want to add to your search index.\n    public function forSearchIndex()\n    {\n\t if ($this-\u003eisPageWithSections()) {\n            $oldThemes = SSViewer::get_themes();\n            SSViewer::set_themes(\n                Config::inst()-\u003eget(SSViewer::class, 'themes')\n            );\n            try {\n                $string = SearchIndexEntry::sanitize_string(\n                    $this-\u003ecustomise([\n                        'RelationName' =\u003e self::SECTIONS\n                    ])-\u003erenderWith('Elements')\n                );\n            } finally {\n                SSViewer::set_themes($oldThemes);\n            }\n            return $string;\n        }\n\n        $contents = [\n            $this-\u003eTitle,\n            $this-\u003eobj('Content')\n                -\u003esetProcessShortcodes(true)\n                -\u003eRAW()\n        ];\n\n        $string = implode($contents, ' ');\n        return $string ? SearchIndexEntry::sanitize_string($string) : null;\n    }\n    \n    public function isPageWithSections()\n    {\n        return isset(\n            ElementsExtension::page_element_relation_names($this)[\n                self::SECTIONS\n            ]\n        );\n    }\n}\n```\n\n### Content stripping\n\nWhen using `SearchIndexEntry::sanitize_string` html tags will be removed from the text.\nIt is possible to mark certain parts of the html to also be removed. This can be handy if you want to strip out navigation elements or breadcrumbs. To accomplish this all content between `\u003c!--\u003cSearchExclude\u003e--\u003e` and `\u003c!--\u003c/SearchExclude\u003e--\u003e` will be ereased:\n\n```html\n\u003c!--\u003cSearchExclude\u003e--\u003e\n    Contents between this comments will be stripped\n\u003c!--\u003c/SearchExclude\u003e--\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farillo%2Fsilverstripe-simple-search","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farillo%2Fsilverstripe-simple-search","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farillo%2Fsilverstripe-simple-search/lists"}