Cecil

Page extends Item

Page class.

Represents a page in the collection, which can be created from a file or be virtual. Provides methods to manage page properties, variables, and rendering.

Table of Contents

Constants

SLUGIFY_PATTERN  = '/(^\/|[^._a-z0-9\/]|-)+/'

Properties

$body  : string
$file  : SplFileInfo
$fmVariables  : array<string|int, mixed>
$folder  : string
$frontmatter  : string
$html  : string
$id  : string
Item's identifier.
$paginator  : array<string|int, mixed>
$path  : string
$properties  : array<string|int, mixed>
Item's properties.
$rendered  : array<string|int, mixed>
$section  : string
$slug  : string
$subPages  : Collection
$terms  : Vocabulary
$type  : Type
$virtual  : bool
$slugifier  : Slugify

Methods

__construct()  : mixed
__toString()  : string
toString magic method to prevent Twig get_attribute fatal error.
addRendered()  : self
Add rendered.
createIdFromFile()  : string
Creates the ID from the file (path).
getBody()  : string|null
Get body as raw.
getBodyHtml()  : string|null
Get body as HTML.
getContent()  : string|null
getFileName()  : string|null
Returns file name, with extension.
getFilePath()  : string|null
Returns file real path.
getFmVariables()  : array<string|int, mixed>
Get front matter variables.
getFolder()  : string|null
Get path without slug.
getFrontmatter()  : string|null
Get front matter.
getId()  : string
Returns the item's identifier.
getIdWithoutLang()  : string
Returns the ID of a page without language.
getPages()  : Collection|null
Get Subpages.
getPagination()  : array<string|int, mixed>
Paginator backward compatibility.
getPaginator()  : array<string|int, mixed>
Get paginator.
getPath()  : string|null
Get path.
getPathname()  : string|null
getRendered()  : array<string|int, mixed>
Get rendered.
getSection()  : string|null
Get section.
getSlug()  : string
Get slug.
getTerms()  : Vocabulary
Get vocabulary terms.
getType()  : string
Get page type.
getVariable()  : mixed|null
Get a variable.
getVariables()  : array<string|int, mixed>
Get all variables.
hasVariable()  : bool
Is variable exists?
isVirtual()  : bool
Is current page is virtual?
offsetExists()  : bool
Implements \ArrayAccess.
offsetGet()  : mixed|null
Implements \ArrayAccess.
offsetSet()  : void
Implements \ArrayAccess.
offsetUnset()  : void
Implements \ArrayAccess.
parse()  : self
Parse file content.
setBodyHtml()  : self
Set body as HTML.
setFile()  : self
Set file.
setFmVariables()  : self
Set front matter (only) variables.
setFolder()  : self
Set path without slug.
setId()  : self
Set the item's identifier.
setPages()  : self
Set Subpages.
setPaginator()  : self
Set paginator.
setPath()  : self
Set path.
setSection()  : self
Set section.
setSlug()  : self
Set slug.
setTerms()  : self
Set vocabulary terms.
setType()  : self
Set page type.
setVariable()  : self
Set a variable.
setVariables()  : self
Set an array as variables.
setVirtual()  : self
Set virtual status.
slugify()  : string
Turns a path (string) into a slug (URI).
toArray()  : array<string|int, mixed>
Returns properties as array.
unSection()  : self
Unset section.
unVariable()  : self
Unset a variable.
filterBool()  : bool|mixed
Cast "boolean" string (or array of strings) to boolean.

Constants

SLUGIFY_PATTERN

public mixed SLUGIFY_PATTERN = '/(^\/|[^._a-z0-9\/]|-)+/'

Properties

$body

protected string $body

Body before conversion.

$file

protected SplFileInfo $file

$fmVariables

protected array<string|int, mixed> $fmVariables = []

Front matter before conversion.

$folder

protected string $folder

$frontmatter

protected string $frontmatter

$html

protected string $html

Body after conversion.

$id

Item's identifier.

protected string $id

$paginator

protected array<string|int, mixed> $paginator = []

$path

protected string $path

path = folder + slug.

$properties

Item's properties.

protected array<string|int, mixed> $properties = []

$rendered

protected array<string|int, mixed> $rendered = []

Output, by format

$section

protected string $section

$slug

protected string $slug

$virtual

protected bool $virtual

True if page is not created from a file.

$slugifier

private static Slugify $slugifier

Methods

__construct()

public __construct(string $id) : mixed
Parameters
$id : string

__toString()

toString magic method to prevent Twig get_attribute fatal error.

public __toString() : string
Return values
string

addRendered()

Add rendered.

public addRendered(array<string|int, mixed> $rendered) : self
Parameters
$rendered : array<string|int, mixed>
Return values
self

createIdFromFile()

Creates the ID from the file (path).

public static createIdFromFile(SplFileInfo $file) : string
Parameters
$file : SplFileInfo
Return values
string

getBody()

Get body as raw.

public getBody() : string|null
Return values
string|null

getBodyHtml()

Get body as HTML.

public getBodyHtml() : string|null
Return values
string|null

getContent()

public getContent() : string|null
Tags
see
getBodyHtml()
Return values
string|null

getFileName()

Returns file name, with extension.

public getFileName() : string|null
Return values
string|null

getFilePath()

Returns file real path.

public getFilePath() : string|null
Return values
string|null

getFmVariables()

Get front matter variables.

public getFmVariables() : array<string|int, mixed>
Return values
array<string|int, mixed>

getFolder()

Get path without slug.

public getFolder() : string|null
Return values
string|null

getFrontmatter()

Get front matter.

public getFrontmatter() : string|null
Return values
string|null

getId()

Returns the item's identifier.

public getId() : string
Return values
string

getIdWithoutLang()

Returns the ID of a page without language.

public getIdWithoutLang() : string
Return values
string

getPagination()

Paginator backward compatibility.

public getPagination() : array<string|int, mixed>
Return values
array<string|int, mixed>

getPaginator()

Get paginator.

public getPaginator() : array<string|int, mixed>
Return values
array<string|int, mixed>

getPath()

Get path.

public getPath() : string|null
Return values
string|null

getPathname()

public getPathname() : string|null
Tags
see
getPath()
Return values
string|null

getRendered()

Get rendered.

public getRendered() : array<string|int, mixed>
Return values
array<string|int, mixed>

getSection()

Get section.

public getSection() : string|null
Return values
string|null

getSlug()

Get slug.

public getSlug() : string
Return values
string

getType()

Get page type.

public getType() : string
Return values
string

getVariable()

Get a variable.

public getVariable(string $name[, mixed|null $default = null ]) : mixed|null
Parameters
$name : string

Name of the variable

$default : mixed|null = null

Default value

Return values
mixed|null

getVariables()

Get all variables.

public getVariables() : array<string|int, mixed>
Return values
array<string|int, mixed>

hasVariable()

Is variable exists?

public hasVariable(string $name) : bool
Parameters
$name : string

Name of the variable

Return values
bool

isVirtual()

Is current page is virtual?

public isVirtual() : bool
Return values
bool

offsetExists()

Implements \ArrayAccess.

public offsetExists(mixed $offset) : bool
Parameters
$offset : mixed
Attributes
#[ReturnTypeWillChange]
Return values
bool

offsetGet()

Implements \ArrayAccess.

public offsetGet(mixed $offset) : mixed|null
Parameters
$offset : mixed
Attributes
#[ReturnTypeWillChange]
Return values
mixed|null

offsetSet()

Implements \ArrayAccess.

public offsetSet(mixed $offset, mixed $value) : void
Parameters
$offset : mixed
$value : mixed
Attributes
#[ReturnTypeWillChange]

offsetUnset()

Implements \ArrayAccess.

public offsetUnset(mixed $offset) : void
Parameters
$offset : mixed
Attributes
#[ReturnTypeWillChange]

parse()

Parse file content.

public parse() : self
Return values
self

setBodyHtml()

Set body as HTML.

public setBodyHtml(string $html) : self
Parameters
$html : string
Return values
self

setFile()

Set file.

public setFile(SplFileInfo $file) : self
Parameters
$file : SplFileInfo
Return values
self

setFmVariables()

Set front matter (only) variables.

public setFmVariables(array<string|int, mixed> $variables) : self
Parameters
$variables : array<string|int, mixed>
Return values
self

setFolder()

Set path without slug.

public setFolder(string $folder) : self
Parameters
$folder : string
Return values
self

setId()

Set the item's identifier.

public setId(string $id) : self
Parameters
$id : string
Return values
self

setPages()

Set Subpages.

public setPages(Collection $subPages) : self
Parameters
$subPages : Collection
Return values
self

setPaginator()

Set paginator.

public setPaginator(array<string|int, mixed> $paginator) : self
Parameters
$paginator : array<string|int, mixed>
Return values
self

setPath()

Set path.

public setPath(string $path) : self
Parameters
$path : string
Return values
self

setSection()

Set section.

public setSection(string $section) : self
Parameters
$section : string
Return values
self

setSlug()

Set slug.

public setSlug(string $slug) : self
Parameters
$slug : string
Return values
self

setTerms()

Set vocabulary terms.

public setTerms(Vocabulary $terms) : self
Parameters
$terms : Vocabulary
Return values
self

setType()

Set page type.

public setType(string $type) : self
Parameters
$type : string
Return values
self

setVariable()

Set a variable.

public setVariable(string $name, mixed $value) : self
Parameters
$name : string

Name of the variable

$value : mixed

Value of the variable

Tags
throws
RuntimeException
Return values
self

setVariables()

Set an array as variables.

public setVariables(array<string|int, mixed> $variables) : self
Parameters
$variables : array<string|int, mixed>
Tags
throws
RuntimeException
Return values
self

setVirtual()

Set virtual status.

public setVirtual(bool $virtual) : self
Parameters
$virtual : bool
Return values
self

slugify()

Turns a path (string) into a slug (URI).

public static slugify(string $path) : string
Parameters
$path : string
Return values
string

toArray()

Returns properties as array.

public toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

unSection()

Unset section.

public unSection() : self
Return values
self

unVariable()

Unset a variable.

public unVariable(string $name) : self
Parameters
$name : string

Name of the variable

Return values
self

filterBool()

Cast "boolean" string (or array of strings) to boolean.

private filterBool(mixed &$value) : bool|mixed
Parameters
$value : mixed

Value to filter

Tags
see
strToBool()
Return values
bool|mixed
 
On this page

Search results