Pages 模板文件通常位于某一个主题目录底下的/pages 文件夹下,其命名不影响route。 这些文件都以 .htm 为拓展名。
Pages的三部分
1. Page Configration:定义了页面的一些属性
PARAMETER | DESCRIPTION |
---|---|
url | the page URL, required. |
title | the page title, required. |
layout | the page layout, optional. If specified, should contain the name of the layout file, without extension, for example:default . |
description | the page description for the back-end interface, optional. |
URL的使用:
(1)通过url传递参数:
This is how you can access the URL parameter from the page PHP section
url = "/blog/post/:post_id"
==
function onStart()
{
$post_id = $this->param('post_id');
}
==
(2)使用表达式
url = "/blog/:post_id|^[0-9]+$/comments" - this will match /blog/post/10/comments
...
url = "/blog/:post_id|^[0-9]+$" - this will match /blog/post/3
...
url = "/blog/:post_name?|^[a-z0-9\-]+$" - this will match /blog/my-blog-post
-blog-post
(3)使用通配符
For example, a URL like /color/:color/make/:make*/edit
will match /color/brown/make/volkswagen/beetle/retro/edit
and extract the following parameter values:
- color:
brown
- make:
volkswagen/beetle/retro
2. PHP code
这一部分存在三个特殊的函数:onInit() onStart() onEnd()
(1)onInit() is executed when all components are initialized and before AJAX requests are handled
(2)onStart() is executed in the beginning of the page execution
(3)onEnd() is executed before the page is rendered and after the page components are executed.
他们的执行先后顺序如下:
- Layout
onInit()
function. - Page
onInit()
function. - Layout
onStart()
function. - Layout components
onRun()
method. - Layout
onBeforePageStart()
function. - Page
onStart()
function. - Page components
onRun()
method. - Page
onEnd()
function. - Layout
onEnd()
function.