This extension uses the structure of the page file location in the .\lot\page
folder to enable the basic functions of a web site. This extension also adds some useful properties to the $site
and $state
variable.
Page
A page is a plain text file stored in the .\lot\page
folder. The correct file name format for a page consists of the characters a
, b
, c
, d
, e
, f
, g
, h
, i
, j
, k
, l
, m
, n
, o
, p
, q
, r
, s
, t
, u
, v
, w
, x
, y
, z
, 0
, 1
, 2
, 3
, 4
, 5
, 6
, 7
, 8
, 9
, and -
. The characters .
and _
can also be used, but should be used sparingly, as not all GUI applications like to preserve these characters for security reasons:
.\
└── lot\
└── page\
├── dolor-sit-amet.page ✔
├── lorem-ipsum.page ✔
└── no-no-no.page ✔
A .page
extension is the default file extension for page files to indicate that the page is active and publicly viewable. There are several other page file extensions that can also be used:
.page
- Publicly available and appear together in the list of public pages.
.archive
- Publicly available, but does not appear together in the list of public pages.
.draft
- Not publicly available and will not appear together in the list of public pages.
For example, to access and read the .\lot\page\lorem-ipsum.page
file from the web site, visit http://127.0.0.1/lorem-ipsum
.
A minimum page file content consists of a text. Any text. With optional header data written in YAML syntax:
---
title: Page Title
description: Page description.
type: HTML
...
<p>This page content is valid.</p>
<p>This page content is also valid.</p>
Any missing header data will be replaced by the default data that is automatically generated. Let’s say that the default data is loaded first and then overwritten by the header data of the current page. Most of the default data is just an empty string or null
, which in most cases can also be evaluated as a boolean false
:
return [
'x' => [
'page' => [
'page' => [
'author' => null,
'description' => null,
'title' => null,
'type' => 'Markdown'
]
]
]
];
A folder with the same name as the page name can also link a page file to other files:
.\
└── lot\
└── page\
├── lorem-ipsum\ ✔
├── dolor-sit-amet.page
├── lorem-ipsum.page
└── no-no-no.page
Users can store other data related to the page file in this folder. If the file name ends with the extension .data
, this file will act as an external page property. This is called data.
Data
External data has a higher priority than internal header data because they are easier to parse. So if you have a title.data
file in the .\lot\page\lorem-ipsum
folder, the contents of that file will overwrite the title property written in the page file:
.\
└── lot\
└── page\
├── lorem-ipsum\
│ ├── author.data ✔
│ ├── description.data ✔
│ └── title.data ✔
├── dolor-sit-amet.page
├── lorem-ipsum.page
└── no-no-no.page
Users can also add other page files to the folder. These can then be called as child pages. Child pages override the page view of the current file and change the page view to a list of child pages:
.\
└── lot\
└── page\
├── lorem-ipsum\
│ ├── author.data
│ ├── description.data
│ ├── title.data
│ ├── lorem-ipsum-child-1.page ✔
│ ├── lorem-ipsum-child-2.page ✔
│ └── lorem-ipsum-child-3.page ✔
├── dolor-sit-amet.page
├── lorem-ipsum.page
└── no-no-no.page
Place an empty file named .archive
or .page
in the folder to disable the page listing view in a particular folder:
.\
└── lot\
└── page\
├── lorem-ipsum\
│ └── .page ✔
└── lorem-ipsum.page
And so on…
.\
└── lot\
└── page\
├── lorem-ipsum\
│ ├── lorem-ipsum-child-1\
│ │ ├── author.data
│ │ ├── description.data
│ │ ├── title.data
│ │ ├── lorem-ipsum-child-1-1.page
│ │ ├── lorem-ipsum-child-1-2.page
│ │ └── lorem-ipsum-child-1-3.page
│ ├── author.data
│ ├── description.data
│ ├── title.data
│ ├── lorem-ipsum-child-1.page
│ ├── lorem-ipsum-child-2.page
│ └── lorem-ipsum-child-3.page
├── dolor-sit-amet.page
├── lorem-ipsum.page
└── no-no-no.page
These page conditional statements are available to quickly determine the type of page we are on:
$site->has('next')
- Returns
true
if it is possible to go to the next page. $site->has('page')
- Returns
true
if there is a page to load. $site->has('pages')
- Returns
true
if there are pages to load. $site->has('parent')
- Returns
true
if current page has parent page. $site->has('prev')
- Returns
true
if it is possible to go to the previous page. $site->is('error')
- Returns
404
if there is no page or pages to load. $site->is('home')
- Returns
true
on home page. $site->is('page')
- Returns
true
on single page view. $site->is('pages')
- Returns
true
on multiple page view.
0 Comments
No comments yet.