Pages
in package
Class Pages
Table of Contents
Properties
- $active_lang : string
- $base : string
- $baseRoute : array<string|int, string>
- $blueprints : Blueprints
- $check_method : string
- $children : array<string|int, mixed>
- $enable_pages : bool
- $fire_events : bool
- $grav : Grav
- $home_route : string|null
- $ignore_files : array<string|int, string>
- $ignore_folders : array<string|int, string>
- $ignore_hidden : bool
- $index : array<string|int, PageInterface|string>
- $initialized : bool
- $instances : array<string|int, PageInterface>
- $last_modified : int
- $pages_cache_id : string
- $routes : array<string|int, string>
- $simple_pages_hash : string
- $sort : array<string|int, mixed>
- $types : Types|null
- $directory : FlexDirectory|null
Methods
- __construct() : mixed
- Constructor
- accessLevels() : array<string|int, mixed>
- Get access levels of the site pages
- addPage() : void
- Adds a page and assigns a route to it.
- all() : Collection
- Get all pages
- ancestor() : PageInterface|null
- Get a page ancestor.
- base() : string
- Get or set base path for the pages.
- baseRoute() : string
- Get base route for Grav pages.
- baseUrl() : string
- Get base URL for Grav pages.
- blueprints() : Blueprint
- Get a blueprint for a page type.
- children() : Collection
- Get children of the path.
- disablePages() : void
- Method used in admin to disable frontend pages from being initialized.
- dispatch() : PageInterface|null
- Dispatch URI to a page.
- enablePages() : void
- Method used in admin to later load frontend pages.
- find() : PageInterface|null
- Find a page based on route.
- get() : PageInterface|null
- Get a page instance.
- getCollection() : PageCollectionInterface|Collection
- Get a collection of pages in the given context.
- getDirectory() : FlexDirectory|null
- getHomeRoute() : string
- Gets the home route
- getList() : array<string|int, mixed>
- Get list of route/title of all pages. Title is in HTML.
- getPagesCacheId() : null|string
- Get the Pages cache ID
- getSimplePagesHash() : null|string
- Get the simple pages hash that is not md5 encoded, and isn't specific to language
- getTypes() : Types
- Get available page types.
- homeUrl() : string
- Get home URL for Grav site.
- inherited() : PageInterface|null
- Get a page ancestor trait.
- init() : void
- Class initialization. Must be called before using this class.
- instances() : array<string|int, PageInterface>
- Returns a list of all pages.
- lastModified() : int|null
- Get or set last modification time.
- modularTypes() : array<string|int, mixed>
- Get available page types.
- pageTypes() : array<string|int, mixed>
- Get template types based on page type (standard or modular)
- parents() : array<string|int, mixed>
- Get available parents routes
- parentsRawRoutes() : array<string|int, mixed>
- Get available parents raw routes.
- referrerRoute() : string|null
- Get relative referrer route and language code. Returns null if the route isn't within the current base, language (if set) and route.
- register() : void
- reset() : void
- Reset pages (used in search indexing etc).
- resetHomeRoute() : string|null
- Needed for testing where we change the home route via config
- resetPages() : void
- Accessible method to manually reset the pages cache
- root() : PageInterface
- Get root page.
- route() : string
- Get route for Grav site.
- routes() : array<string|int, mixed>
- Returns a list of all routes.
- setCheckMethod() : void
- sort() : array<string|int, mixed>
- Sort sub-pages in a page.
- types() : array<string|int, mixed>
- Get available page types.
- url() : string
- Get URL for Grav site.
- arrayShuffle() : array<string|int, mixed>
- Shuffles an associative array
- buildFlexPages() : void
- buildRegularPages() : void
- buildRootPage() : Page
- evaluate() : Collection
- findSiteBasedRoute() : PageInterface|null
- Check site based routes.
- getPagesPaths() : array<string|int, mixed>
- getVersion() : string
- initFlexPages() : void
- getParents() : array<string|int, mixed>
- Get available parents routes
Properties
$active_lang
protected
string
$active_lang
$base
protected
string
$base
= ''
$baseRoute
protected
array<string|int, string>
$baseRoute
= []
$blueprints
protected
Blueprints
$blueprints
$check_method
protected
string
$check_method
$children
protected
array<string|int, mixed>
$children
$enable_pages
protected
bool
$enable_pages
= true
$fire_events
protected
bool
$fire_events
= false
$grav
protected
Grav
$grav
$home_route
protected
static string|null
$home_route
$ignore_files
protected
array<string|int, string>
$ignore_files
$ignore_folders
protected
array<string|int, string>
$ignore_folders
$ignore_hidden
protected
bool
$ignore_hidden
$index
protected
array<string|int, PageInterface|string>
$index
= []
$initialized
protected
bool
$initialized
= false
$instances
protected
array<string|int, PageInterface>
$instances
= []
$last_modified
protected
int
$last_modified
$pages_cache_id
protected
string
$pages_cache_id
$routes
protected
array<string|int, string>
$routes
= []
$simple_pages_hash
protected
string
$simple_pages_hash
$sort
protected
array<string|int, mixed>
$sort
$types
protected
static Types|null
$types
$directory
private
FlexDirectory|null
$directory
Methods
__construct()
Constructor
public
__construct(Grav $grav) : mixed
Parameters
- $grav : Grav
accessLevels()
Get access levels of the site pages
public
accessLevels() : array<string|int, mixed>
Return values
array<string|int, mixed>addPage()
Adds a page and assigns a route to it.
public
addPage(PageInterface $page[, string|null $route = null ]) : void
Parameters
- $page : PageInterface
-
Page to be added.
- $route : string|null = null
-
Optional route (uses route from the object if not set).
all()
Get all pages
public
all([PageInterface|null $current = null ]) : Collection
Parameters
- $current : PageInterface|null = null
Return values
Collectionancestor()
Get a page ancestor.
public
ancestor(string $route[, string|null $path = null ]) : PageInterface|null
Parameters
- $route : string
-
The relative URL of the page
- $path : string|null = null
-
The relative path of the ancestor folder
Return values
PageInterface|nullbase()
Get or set base path for the pages.
public
base([string|null $path = null ]) : string
Parameters
- $path : string|null = null
Return values
stringbaseRoute()
Get base route for Grav pages.
public
baseRoute([string|null $lang = null ]) : string
Parameters
- $lang : string|null = null
-
Optional language code for multilingual routes.
Return values
stringbaseUrl()
Get base URL for Grav pages.
public
baseUrl([string|null $lang = null ][, bool|null $absolute = null ]) : string
Parameters
- $lang : string|null = null
-
Optional language code for multilingual links.
- $absolute : bool|null = null
-
If true, return absolute url, if false, return relative url. Otherwise return default.
Return values
stringblueprints()
Get a blueprint for a page type.
public
blueprints(string $type) : Blueprint
Parameters
- $type : string
Return values
Blueprintchildren()
Get children of the path.
public
children(string $path) : Collection
Parameters
- $path : string
Return values
CollectiondisablePages()
Method used in admin to disable frontend pages from being initialized.
public
disablePages() : void
dispatch()
Dispatch URI to a page.
public
dispatch(string $route[, bool $all = false ][, bool $redirect = true ]) : PageInterface|null
Parameters
- $route : string
-
The relative URL of the page
- $all : bool = false
-
If true, return also non-routable pages, otherwise return null if page isn't routable
- $redirect : bool = true
-
If true, allow redirects
Tags
Return values
PageInterface|nullenablePages()
Method used in admin to later load frontend pages.
public
enablePages() : void
find()
Find a page based on route.
public
find(string $route[, bool $all = false ]) : PageInterface|null
Parameters
- $route : string
-
The route of the page
- $all : bool = false
-
If true, return also non-routable pages, otherwise return null if page isn't routable
Return values
PageInterface|nullget()
Get a page instance.
public
get(string $path) : PageInterface|null
Parameters
- $path : string
-
The filesystem full path of the page
Tags
Return values
PageInterface|nullgetCollection()
Get a collection of pages in the given context.
public
getCollection([array<string|int, mixed> $params = [] ][, array<string|int, mixed> $context = [] ]) : PageCollectionInterface|Collection
Parameters
- $params : array<string|int, mixed> = []
- $context : array<string|int, mixed> = []
Return values
PageCollectionInterface|CollectiongetDirectory()
public
getDirectory() : FlexDirectory|null
Return values
FlexDirectory|nullgetHomeRoute()
Gets the home route
public
static getHomeRoute() : string
Return values
stringgetList()
Get list of route/title of all pages. Title is in HTML.
public
getList([PageInterface|null $current = null ][, int $level = 0 ][, bool $rawRoutes = false ][, bool $showAll = true ][, bool $showFullpath = false ][, bool $showSlug = false ][, bool $showModular = false ][, bool $limitLevels = false ]) : array<string|int, mixed>
Parameters
- $current : PageInterface|null = null
- $level : int = 0
- $rawRoutes : bool = false
- $showAll : bool = true
- $showFullpath : bool = false
- $showSlug : bool = false
- $showModular : bool = false
- $limitLevels : bool = false
Return values
array<string|int, mixed>getPagesCacheId()
Get the Pages cache ID
public
getPagesCacheId() : null|string
this is particularly useful to know if pages have changed and you want
to sync another cache with pages cache - works best in onPagesInitialized()
Return values
null|stringgetSimplePagesHash()
Get the simple pages hash that is not md5 encoded, and isn't specific to language
public
getSimplePagesHash() : null|string
Return values
null|stringgetTypes()
Get available page types.
public
static getTypes() : Types
Return values
TypeshomeUrl()
Get home URL for Grav site.
public
homeUrl([string|null $lang = null ][, bool|null $absolute = null ]) : string
Parameters
- $lang : string|null = null
-
Optional language code for multilingual links.
- $absolute : bool|null = null
-
If true, return absolute url, if false, return relative url. Otherwise return default.
Return values
stringinherited()
Get a page ancestor trait.
public
inherited(string $route[, string|null $field = null ]) : PageInterface|null
Parameters
- $route : string
-
The relative route of the page
- $field : string|null = null
-
The field name of the ancestor to query for
Return values
PageInterface|nullinit()
Class initialization. Must be called before using this class.
public
init() : void
instances()
Returns a list of all pages.
public
instances() : array<string|int, PageInterface>
Return values
array<string|int, PageInterface>lastModified()
Get or set last modification time.
public
lastModified([int|null $modified = null ]) : int|null
Parameters
- $modified : int|null = null
Return values
int|nullmodularTypes()
Get available page types.
public
static modularTypes() : array<string|int, mixed>
Return values
array<string|int, mixed>pageTypes()
Get template types based on page type (standard or modular)
public
static pageTypes([string|null $type = null ]) : array<string|int, mixed>
Parameters
- $type : string|null = null
Return values
array<string|int, mixed>parents()
Get available parents routes
public
static parents() : array<string|int, mixed>
Return values
array<string|int, mixed>parentsRawRoutes()
Get available parents raw routes.
public
static parentsRawRoutes() : array<string|int, mixed>
Return values
array<string|int, mixed>referrerRoute()
Get relative referrer route and language code. Returns null if the route isn't within the current base, language (if set) and route.
public
referrerRoute(string|null &$langCode[, string $route = '/' ]) : string|null
Parameters
- $langCode : string|null
-
Variable to store the language code. If already set, check only against that language.
- $route : string = '/'
-
Optional route within the site.
Tags
Return values
string|nullregister()
public
register() : void
reset()
Reset pages (used in search indexing etc).
public
reset() : void
resetHomeRoute()
Needed for testing where we change the home route via config
public
static resetHomeRoute() : string|null
Return values
string|nullresetPages()
Accessible method to manually reset the pages cache
public
resetPages(array<string|int, mixed> $pages_dirs) : void
Parameters
- $pages_dirs : array<string|int, mixed>
root()
Get root page.
public
root() : PageInterface
Tags
Return values
PageInterfaceroute()
Get route for Grav site.
public
route([string $route = '/' ][, string|null $lang = null ]) : string
Parameters
- $route : string = '/'
-
Optional route to the page.
- $lang : string|null = null
-
Optional language code for multilingual links.
Return values
stringroutes()
Returns a list of all routes.
public
routes() : array<string|int, mixed>
Return values
array<string|int, mixed>setCheckMethod()
public
setCheckMethod(string $method) : void
Parameters
- $method : string
sort()
Sort sub-pages in a page.
public
sort(PageInterface $page[, string|null $order_by = null ][, string|null $order_dir = null ][, mixed $sort_flags = null ]) : array<string|int, mixed>
Parameters
- $page : PageInterface
- $order_by : string|null = null
- $order_dir : string|null = null
- $sort_flags : mixed = null
Return values
array<string|int, mixed>types()
Get available page types.
public
static types() : array<string|int, mixed>
Return values
array<string|int, mixed>url()
Get URL for Grav site.
public
url([string $route = '/' ][, string|null $lang = null ][, bool|null $absolute = null ]) : string
Parameters
- $route : string = '/'
-
Optional route to the page.
- $lang : string|null = null
-
Optional language code for multilingual links.
- $absolute : bool|null = null
-
If true, return absolute url, if false, return relative url. Otherwise return default.
Return values
stringarrayShuffle()
Shuffles an associative array
protected
arrayShuffle(array<string|int, mixed> $list) : array<string|int, mixed>
Parameters
- $list : array<string|int, mixed>
Return values
array<string|int, mixed>buildFlexPages()
protected
buildFlexPages(FlexDirectory $directory) : void
Parameters
- $directory : FlexDirectory
buildRegularPages()
protected
buildRegularPages() : void
buildRootPage()
protected
buildRootPage() : Page
Return values
Pageevaluate()
protected
evaluate(array<string|int, mixed>|string $value[, PageInterface|null $self = null ]) : Collection
Parameters
- $value : array<string|int, mixed>|string
- $self : PageInterface|null = null
Return values
CollectionfindSiteBasedRoute()
Check site based routes.
protected
findSiteBasedRoute(string $route) : PageInterface|null
Parameters
- $route : string
Return values
PageInterface|nullgetPagesPaths()
protected
getPagesPaths() : array<string|int, mixed>
Return values
array<string|int, mixed>getVersion()
protected
getVersion() : string
Return values
stringinitFlexPages()
protected
initFlexPages() : void
getParents()
Get available parents routes
private
static getParents(bool $rawRoutes) : array<string|int, mixed>
Parameters
- $rawRoutes : bool
-
get the raw route or the normal route