Laravel 之October Pages

来源:互联网 发布:淘宝开店认证需要等吗? 编辑:程序博客网 时间:2024/06/05 00:38

Pages 模板文件通常位于某一个主题目录底下的/pages 文件夹下,其命名不影响route。 这些文件都以 .htm 为拓展名。

 

Pages的三部分

1. Page Configration:定义了页面的一些属性

PARAMETERDESCRIPTIONurlthe page URL, required.titlethe page title, required.layoutthe page layout, optional. If specified, should contain the name of the layout file, without extension, for example:default.descriptionthe 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. 

他们的执行先后顺序如下:

  1. Layout onInit() function.
  2. Page onInit() function.
  3. Layout onStart() function.
  4. Layout components onRun() method.
  5. Layout onBeforePageStart() function.
  6. Page onStart() function.
  7. Page components onRun() method.
  8. Page onEnd() function.
  9. Layout onEnd() function.

 

0 0
原创粉丝点击