-
-
Notifications
You must be signed in to change notification settings - Fork 5
Dynamic URIs
Static file mapping is enough for many pages, but real applications often need one page to handle many similar URLs. A blog article, product page, user profile, or category listing are all common examples.
Note
You'll see the term "URI" used alongside "URL" and sometimes "URN" when reading web development documentation. In most everyday web development, URI and URL are used interchangeably.
WebEngine uses @ markers in file and directory names to represent dynamic parts of the path.
For example:
page/blog/@slug.htmlpage/shop/@category/@product.html
If the browser requests /blog/hello-world, WebEngine can match that to page/blog/@slug.html. The same view and logic files can then be reused for every blog post.
@@ is used for a deeper catch-all style of matching, where one dynamic part may represent more than one path segment. That is useful more rarely, but it allows broader matching when a single-segment @name route is not enough.
The values captured from the path are made available through the dynamic path object in page logic, so the application code can read values such as the current slug or category.
Good URIs are readable and stable. A path such as /blog/hello-world usually tells us more than /post?id=42, and it maps neatly to the file structure at the same time.
The URI is also part of the application's interface. Users bookmark it, share it, and rely on it when moving around the site. Keeping the path meaningful usually leads to clearer code as well.
One dynamic page can serve many related requests. The matching page logic file can then use the captured path values to load the right data, handle 404s for missing records, and bind the correct content into the page.
That gives us reuse without giving up the file-based model.
Let's move on to how page headers and footers can be added automatically, or jump ahead to page partials.
- File-based routing
- Page views
- Page logic
- Dynamic URIs
- Headers and footers
- Custom HTML components
- Page partials
- Binding data to the DOM
- DOM manipulation
- Hello You tutorial
- Todo list tutorial
- Address book tutorial WIP
- Blueprints
- Application architecture
- Coding styleguide WIP
- PHP environment setup WIP
- Web servers WIP
- Background cron tasks
- Database setup WIP
- Client-side compilation WIP
- Testing WebEngine applications WIP
- Production checklist WIP
- Security WIP