SearchController
class SearchController extends ControllerBase
Search controller
Search accepts the following parameters via GET:
- keywords - search keywords
- order - search sort, default is published time, must be a valid property
- direction - sort direction, can be
asc
ordesc
, default is newest first (desc) - tag - comma separated list of inclusive tags to search
- author - comma separated list of inclusive authors to search
- title - items title, headline, filename
- begin - published begin time, in the form of YYYYMMDD
- end - published end time, in the form of YYYYMMDD
- type - content type, article, post, media - by default searches ALL types
Search can also work in compatibility mode if a=1
or q=
are present in the query
string. In that case, the following substitutions are made:
IF a=1
is present:
- keywords -> s
- order -> d
- direction -> o
- tag -> tg
- author -> au
- title -> ti
- type -> ty
- ts_* -> begin
- te_* -> end
IF q=string
is present:
- keywords -> q
- order -> "published_at"
- direction -> "desc"
- tag -> NULL
- author -> NULL
- title -> NULL
- type -> NULL
- ts_* -> NULL
- te_* -> NULL
Methods
Enables path to Gryphon compatible view, if the view exists AND enableCompatibility is on.
Terminate the action with a view partial. Will dump output directly to browser, but return the action allowing process to continue.
Search action, by URLs in the form of:
Build collection of items. Casts search results as proper model types.
Build the pagination object
Details
in ControllerBase at line 16
initialize()
Initialize response headers
in ControllerBase at line 44
protected boolean
enableCompatibilityView(string $view)
Enables path to Gryphon compatible view, if the view exists AND enableCompatibility is on.
NOTE: This will mutate the internal view.
in ControllerBase at line 62
protected
terminateWithView(string $view, array $params = [], array $headers = [])
Terminate the action with a view partial. Will dump output directly to browser, but return the action allowing process to continue.
in ControllerBase at line 88
protected
getHttpCodeDescription($code)
in ControllerBase at line 152
protected mixed
getRequestSegments(int $i = null)
Return rewrite url segments
in ControllerBase at line 172
protected array
getJsonData()
Fetch POSTed/PUTed json data
at line 77
indexAction()
Search action, by URLs in the form of:
search
Returns the following items to the view:
- didSearch - boolean
- total - integer
- items - collection of objects {see \Ceo\Models\Article}, {see \Ceo\Models\Post}, {see \Ceo\Models\Media}, {see \Ceo\Search\Result}
- pagination - {see \Ceo\Pagination\Pagination}
- searchParams - array of search parameters, see above
Looks for templates in the following order:
- gryphon/search/advanced.tpl - Compatibility mode
- search/index.twig
Search items implement the Searchable Trait
at line 195
protected array
buildItemCollection(array $matches)
Build collection of items. Casts search results as proper model types.
If model type cannot be determined, will cast as \Ceo\Search\Result type which implements the \Ceo\Traits\Searchable trait.
at line 234
protected Pagination
buildPagination($props, $searchParams)
Build the pagination object