-
-
Couldn't load subscription status.
- Fork 6
Dynamic URIs and Pages
Having the router match all URIs to View and Logic resources is limiting when dynamic content is requested from a URI, such as a blog article at the URI /blog/2009/08/04/example-blog-title. It wouldn't be feasible to have a directory path for every single year, month and day!
A special syntax can be used to indicate to the router that a part of the requested URI is dynamic. The above URI can then link to the Page View file located at page/blog/@year/@month/@day/@title.html. The @title.html file will be served for any request under the blog directory that matches the URI pattern of /blog/year/month/day/title.
The Page View can be made dynamic by a adding Page Logic file at page/blog/@year/@month/@day/@title.php, which can be used to bind the correct data to the document and handle 404 errors for non-matching content.
Each part of the dynamic URI that is prefixed with an @ symbol can be retrieved by the dynamicPath property of the PageLogic class. For example, in the URI /blog/2009/08/04/example-blog-title, $this->dynamicPath->get("year") would return 2009, and $this->dynamicPath->get("title") would return "example-blog-title".
- Request-response lifecycle
- Running your application
- Project layout
- Application architecture
- Web servers
- URIs
- Page view
- Dynamic URIs and pages
- Headers and footers
- Page logic
- Protected globals
- User input
- Cookies
- Sessions
- DOM manipulation
- Custom HTML components
- DOM templates
- Binding data to the DOM
- Database
- Client side assets
- API Webservices
- Security
- Configuration
- Build system
- Coding styleguide