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 or desc, 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

initialize()

Initialize response headers

boolean
enableCompatibilityView(string $view)

Enables path to Gryphon compatible view, if the view exists AND enableCompatibility is on.

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.

getHttpCodeDescription($code)

No description

mixed
getRequestSegments(int $i = null)

Return rewrite url segments

array
getJsonData()

Fetch POSTed/PUTed json data

indexAction()

Search action, by URLs in the form of:

array
buildItemCollection(array $matches)

Build collection of items. Casts search results as proper model types.

buildPagination($props, $searchParams)

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.

Parameters

string $view

Return Value

boolean

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.

Parameters

string $view path
array $params view params
array $headers optional headers

in ControllerBase at line 88
protected getHttpCodeDescription($code)

Parameters

$code

in ControllerBase at line 152
protected mixed getRequestSegments(int $i = null)

Return rewrite url segments

Parameters

int $i segment from 0

Return Value

mixed either all segments as array, or single segment

in ControllerBase at line 172
protected array getJsonData()

Fetch POSTed/PUTed json data

Return Value

array

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

See also

\Ceo\Traits\Searchable

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.

Parameters

array $matches

Return Value

array

See also

\Ceo\Search\Result
\Ceo\Traits\Searchable

at line 234
protected Pagination buildPagination($props, $searchParams)

Build the pagination object

Parameters

$props
$searchParams

Return Value

Pagination

See also

\Ceo\Pagination\Pagination