Skip to content
Johan Janssens edited this page Mar 10, 2021 · 87 revisions

A page is the fundamental building block of Joomlatools Pages and is a special type of template. This is where you write your content to be displayed in the frontend.

By default, pages files are loaded from the /pages directory. They have the ability to create URLs based on how they are arranged in your folder tree.

Table of contents

Frontmatter

The headers (alternatively known as frontmatter) at the top of a page are completely optional, you don't need headers at all for a page to display.

The page frontmatter contains useful information about your page such as the title, description, layout, and so on. The frontmatter block begins and ends with triple-dashed lines (---).

Page properties are defined in the frontmatter using YAML. All properties are lowercase and are accessible in the page templates using $[property].

Default properties

The page object supports the following built-in properties:

---
layout: default
name: Page
title: The title of the page
summary: A super-duper summary for this page.
slug: The slug of the page used in URLs
content: The content of the page
text: The text of the page
excerpt: The excerpt of the page
image: An image for the page
date: 2018-01-17 14:30:15
author: The author of the page
published: true
category: ''
redirect: http://www.joomlatools.com
access:
    roles: [public]
    groups: [public, guest]
metadata:
    generator: Joomlatools
    keywords: HTML, CSS, XML, JavaScript
    author: John Smith
    robots: noindex, nofollow
process: 
     filters: []
collection: false
language: en-GB
direction: rtl
---

All the frontmatter properties are available as variables in the page except for the layout property which is used to load the layout of the page.

Note: The content, text and excerpt properties are based on the content of the page. Setting them as part of the frontmatter will override the page content.

Custom properties

Custom properties can be defined in the frontmatter and they then become available in the page. If the page is part of a collection the property can also be used as a filter (See: Collection > State)

Layout

This is used to render a page. By default, the built-in default layout is used. You can create your own layouts as template overrides then set them here.

See also: Templates > Layouts

Name

The name of the page used for example to generate a menu item. The name should be one or two words maximum. By default, the name is created from the slug.

Title

The title of the page used in the HTML document metadata, and for Opengraph metadata.

Summary

The summary of the page. If no metadata description is defined the summary will be used for the metadata description.

Slug

The slug is used when generating URLs for the page. If no slug is defined a slug is created from the page title.

Content

The rendered content of the page. If the page hasn't been rendered yet, the content will be empty.

Text

A page has an additional text parameter that gives you access to the text of the page. If the page includes a <!--more--> tag, it will return the text below the tag.

Excerpt

The excerpt is the part of the page above the <!--more--> tag. If no tag exists, the excerpt will return empty.

Image

The image for the page. Can be an absolute internal path or an external URL. The image is used in the Opengraph metadata

Date

The date the page was created. If not set, this defaults to the last modified time of the page file on disk.

A date can be specified in different formats:

  • Y-M-D H:M:S +/-T (Hours, minutes, seconds, and timezone offset are optional)
  • M/D/Y H:M:S +/-T (Hours, minutes, seconds, and timezone offset are optional)
  • D-M-Y H:M:S +/-T (Hours, minutes, seconds, and timezone offset are optional)

Dates can be in different formats. The m/d/y or d-m-y formats are disambiguated by looking at the separator between the various components. If the separator is a slash (/), then the American m/d/y is assumed; whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed.

For other formats see: PHP DateTime Class

Dynamic date properties

A page also has the following dynamic date properties:

  • year
  • month
  • day

They give easy access to the year, month and day.

Author

The author of the page

Published

Valid values are true or false. By default, a page is published unless you explicitly set published: false.

Category

The category for the page. For collections, the category reflects the directory that the page is in.

Access

The access defines which user can access the page. This has two sub-properties:

  • Groups: an array of users groups the user needs to be part of in order to access the page. Default: [public, guest]
  • Roles: an array of access levels the user needs to be part of in order to access the page. Default: [public]

If the user is not part of any of the roles and groups, access is denied.

Metadata

Meta headers allow you to set the standard set of HTML meta tags for each page as well as OpenGraph, Facebook, and Twitter meta tags. The valid value is a named array of headers to set.

See also: Page > Opengraph

Redirect

Redirects to another internal or external page. Accepts an external URL or an internal path.

See also: URLs and Linking > Redirects

Process

Cache

The cache can be disabled per page and the cache time, specified in seconds, can also be set.

Possible values:

  • true: enable caching for the page using default values (default)
  • false: disables caching for the page
  • x: enables caching for the page and sets cache time to x seconds

See also: Advanced > Caching > HTTP Caching

Filters

Additional page filters can be specified. Filters are fired after the page has been rendered.

See also Page > Filters

Decoration

Specify the decoration level which indicates how deep the decoration takes effect.

Possible values:

  • 0: only decorate the specific page
  • x: decorate as deep as x
  • true: decorate all (default)
  • false: do not decorate

See also: Advanced > Decoration

Collection

A collection is a list of data items which is retrieved from a specific source: pages, filesystem, database, or web service.

See also: Collection

Direction

Specifies the base reading direction that text should be displayed in. Some languages are read from left to right, while others are read from right to left.

Possible values:

  • auto : the default value
  • rtl : right-to-left
  • ltr : left-to-right

Note: auto is supported by all HTML5-capable browsers. With this setting, the browser automatically detects the main language on the page and sets the appropriate direction.

Language

Specifies the language of the page. The default value is en-GB.

The page() function

If you want to get information about a page, you can use the page() template function. This method retrieves the page object which contains the page properties such as title, content, layout, etc.

Examples:

page()->title;                // Return the title of the current page.
page('path/to/page')->title;  // Return the title of another page, not the current page.

You can use the page() function with any arguments to retrieve the active page, from any template or layout.

See also: Templates > Functions

Excluding Pages

If you want to exclude a page from being indexed you can prefix it with an '_' underscore. For example '_mypage.html.php'.

If you want to exclude a directory and all of its contents you can include a '.ignore' file in the directory and Pages will not index the directory nor it's contents.

Clone this wiki locally