https://github.com/brandcom/silverstripe-elemental-site-search
Basic site search for the SilverStripe Elemental module
https://github.com/brandcom/silverstripe-elemental-site-search
search silverstripe silverstripe-module
Last synced: about 1 year ago
JSON representation
Basic site search for the SilverStripe Elemental module
- Host: GitHub
- URL: https://github.com/brandcom/silverstripe-elemental-site-search
- Owner: brandcom
- License: mit
- Created: 2019-07-24T07:22:12.000Z (almost 7 years ago)
- Default Branch: 5.x
- Last Pushed: 2024-04-19T11:36:38.000Z (about 2 years ago)
- Last Synced: 2024-11-01T15:41:10.066Z (over 1 year ago)
- Topics: search, silverstripe, silverstripe-module
- Language: PHP
- Size: 21.5 KB
- Stars: 4
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SilverStripe Elemental Site Search Module
Basic site search for the SilverStripe Elemental module. It works by saving a text reprentation of the elemental area to an extra field in SiteTree.
## Requires
* [SilverStripe](https://www.silverstripe.org/)
* [SilverStripe Elemental](https://github.com/dnadesign/silverstripe-elemental)
## Usage
### Install this module with composer
composer require jbennecker/silverstripe-elemental-site-search
Make sure you don't have `FulltextSearchable` enabled in `_config.php`.
### Add the search form
To add the search form, add `$SearchForm` anywhere in your template.
For example in Header.ss
...
$SearchForm
...
### Override the template
Lastly you can override the template for the result page.
app/templates/Layout/Page_results.ss
$Title
<% if $Query %>
You searched for "{$Query}"
<% end_if %>
<% if $Results %>
<% loop $Results %>
-
<% if $MenuTitle %>
$MenuTitle
<% else %>
$Title
<% end_if %>
$Content.LimitWordCountXML
Read more about "{$Title}"...
<% end_loop %>
<% else %>
Sorry, your search query did not return any results.
<% end_if %>
<% if $Results.MoreThanOnePage %>
<% if $Results.NotLastPage %>
Next
<% end_if %>
<% if $Results.NotFirstPage %>
Prev
<% end_if %>
<% loop $Results.Pages %>
<% if $CurrentBool %>
$PageNum
<% else %>
$PageNum
<% end_if %>
<% end_loop %>
Page $Results.CurrentPage of $Results.TotalPages
<% end_if %>
### Clear caches
Then finally add ?flush=1 to the URL and you should see the new template.