CanonicalUrlLatteExtension
extends Extension
in package
`{$url|canonical}` builds the address for `<link rel="canonical">`.
A canonical built from link('this', getParameters()) carries the whole request, so every
combination of theme switcher, list view, sorting and shop filters would be its own
canonical and search engines would report them as duplicates. The filter drops parameters
that do not change the page content and completes a relative address with scheme and host
(search engines expect an absolute canonical).
Only the query string is touched; parameters encoded in the path (route) stay.
Table of Contents
Constants
- DROP : array<string|int, mixed> = ['_theme', '_skin', 'view', 'order', 'count', '...
- Query parameters that are not part of the page identity: theme switcher, list view and sorting (`page` stays because page 2 is different content than page 1), shop filters (the canonical of a filtered category is the unfiltered category), signals and detail context.
Properties
- $httpRequest : IRequest
Methods
- __construct() : mixed
- canonical() : string
- getFilters() : array<string|int, mixed>
Constants
DROP
Query parameters that are not part of the page identity: theme switcher, list view and sorting (`page` stays because page 2 is different content than page 1), shop filters (the canonical of a filtered category is the unfiltered category), signals and detail context.
private
array<string|int, mixed>
DROP
= ['_theme', '_skin', 'view', 'order', 'count', 'spec', 'lspec', 'tag', 'categoryId', 'do', '_fid']
Properties
$httpRequest read-only
private
IRequest
$httpRequest
Methods
__construct()
public
__construct(IRequest $httpRequest) : mixed
Parameters
- $httpRequest : IRequest
canonical()
public
canonical(string $url) : string
Parameters
- $url : string
Return values
stringgetFilters()
public
getFilters() : array<string|int, mixed>