All websites are made up of pages. In TastyIgniter, pages are the most basic building block for content. Page file names or directory structure do not affect the routing, but naming your pages according to the page function is a good idea.
Pages files live in the /_pages subdirectory of a theme directory.
The simplest way to set a permalink is using front matter. You set the permalink variable in the front matter to the URL you’d like. Permalinks should start with the forward slash character and can contain parameters.
For example, you might have a page on your site located at /_pages/common/about.php and you want the url to be /about. In front matter of the page you would set:
For any address such as /pages/my-first-page, a page with the permalink pattern defined in the following example would be displayed.
permalink:"/pages/:title"- this will match /pages/page-title
To make a parameter optional add the question mark after its name:
permalink:"/pages/:title?"- this will match /pages/page-title OR /pages
Parameters can not be optional in the middle of the permalink:
permalink:"/pages/:title?/:slug"- this will match /pages/page-title/page-slug
A default value can be specified after the question mark and used as fallback values in case the real parameter value is not presented. Default values can not contain any asterisks, pipe symbols or question marks.
permalink:"/pages/:title?default"- this will match /pages/page-title OR /pages/default
You could also use regular expressions to validate parameters:
permalink:"/pages/:title|^[a-z0-9\-]+$"- this will match /pages/page-title
A special wildcard parameter can be used by placing the asterisk after the parameter:
permalink:"/pages/:title*/:slug"- this will match /pages/page-title/child/page/page-slug
Execution life cycle
In the PHP code section of pages and layouts there are specific functions: onInit, onStart and onEnd.
The function onInit is executed when all components are initialized and before AJAX requests are handled. The onStart function is executed at the start of the execution of the page. The onEnd function is executed before the page is rendered and the page components are executed.
Return a response from any of the methods defined in the execution life cycle. The life cycle methods have the ability to halt the process when a response is returned. Return Hello world! string to the browser without loading any page contents with the following example: