Documentation

SitemapGen
in package

AbstractYes

Table of Contents

Properties

$flatten_redirects  : bool
$urls  : array<string|int, array{loc: string, mod?: string, freq?: string, prio?: float}>

Methods

build()  : array<string|int, array{loc: string, mod?: string, freq?: string, prio?: float}>
Build the sitemap URLs.
findRedirect()  : null|string
Find a redirect for a given URL.
generate()  : void
Generate sitemap entries by calling the {@see SitemapGen::url} method
normalizeUrl()  : null|array{scheme: string, host: string, path: string, query?: string}
Parse a URL/path and normalise it.
render()  : string
Render a single URL object as XML.
findPageRedirect()  : null|string
Find a page redirect for a given URL.
findStaticRedirect()  : null|string
Find a static redirect for a given URL.
loadRedirects()  : array<string|int, array<string|int, mixed>>
Load redirects for a given host and subsite.
url()  : void
Add a single URL in the sitemap

Properties

$flatten_redirects

public bool $flatten_redirects = true

$urls

protected array<string|int, array{loc: string, mod?: string, freq?: string, prio?: float}> $urls = []

Methods

build()

Build the sitemap URLs.

public build() : array<string|int, array{loc: string, mod?: string, freq?: string, prio?: float}>

This calls generate() and returns the URL objects.

Return values
array<string|int, array{loc: string, mod?: string, freq?: string, prio?: float}>

findRedirect()

Find a redirect for a given URL.

public findRedirect(string $loc) : null|string
Parameters
$loc : string
Return values
null|string

generate()

Generate sitemap entries by calling the {@see SitemapGen::url} method

public abstract generate() : void

normalizeUrl()

Parse a URL/path and normalise it.

public static normalizeUrl(string $loc) : null|array{scheme: string, host: string, path: string, query?: string}

This ensures there is always a scheme, host and path.

The path is stripped of the subsite prefix if present.

Parameters
$loc : string
Return values
null|array{scheme: string, host: string, path: string, query?: string}

render()

Render a single URL object as XML.

public static render(array{loc: string, mod?: string, freq?: string, prio?: float} $url) : string
Parameters
$url : array{loc: string, mod?: string, freq?: string, prio?: float}
Return values
string

findPageRedirect()

Find a page redirect for a given URL.

protected findPageRedirect(string $loc) : null|string
Parameters
$loc : string
Return values
null|string

findStaticRedirect()

Find a static redirect for a given URL.

protected findStaticRedirect(string $loc) : null|string
Parameters
$loc : string
Return values
null|string

loadRedirects()

Load redirects for a given host and subsite.

protected static loadRedirects(string $host, int $subsite_id) : array<string|int, array<string|int, mixed>>
Parameters
$host : string
$subsite_id : int
Return values
array<string|int, array<string|int, mixed>> —

db rows

url()

Add a single URL in the sitemap

protected url(string $loc[, string|int|null $mod = null ][, string|null $freq = null ][, float $prio = 0.5 ]) : void
Parameters
$loc : string

The location. Can be an absolute or relative url

$mod : string|int|null = null

The last modified date. Should be anything parseable by strtotime()

$freq : string|null = null

The frequency of updates. Options include 'always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never'

$prio : float = 0.5

Priority relative to other pages on the site. Range 0.0 (unimportant) to 1.0 (very important)

On this page

Search results