Homepage
Main navigation
Main content
Additional information
Login / Sign up
Quality Guidelines
About
GitHub
Propose new content
Winter CMS resources and help articles
Simple and to the point. Optimized by the community.
×
Login / Sign up
Quality Guidelines
About
GitHub
Propose new content
Edit trick
Changes will be published after manual review
Title
Give your trick a describing title. Do
not
start with «How to...».
Your trick
Keep it short and concise! Markdown is supported.
If you've got the following cms page called `blog-post.htm` in your theme... ``` title = "Blog post" url = "/blog/:slug" layout = "default" is_hidden = 0 [blogPost] == {% component 'blogPost' %} ``` ... you can use the following methods to generate a link to it: ### In Twig Pass the name of the cms page file to the `page` filter. Optionally pass along any URL parameters. ```twig {# Example with parameters #} {{ 'blog-post' | page({slug: 'slug-of-the-post'}) }} {# Example without parameters #} {{ 'blog' | page }} {# Note: If you are linking to a Winter.Pages page, use the staticPage filter #} {{ 'static-blog' | staticPage }} ``` ### In PHP Use the `\Cms\Classes\Controller` class to generate the URL. ```php // In a page or component context you can access the // controller via $this->controller $this->controller->pageUrl('blog-post', ['slug' => 'slug-of-the-post']); // If you don't have access to a controller you can // easily create a new instance on the fly. $url = (new \Cms\Classes\Controller)->pageUrl('blog-post', ['slug' => 'slug-of-the-post']); // Or use the Page class helper \Cms\Classes\Page::url('blog-post', ['slug' => 'slug-of-the-post']) ```
References
Add additional online resources to your trick
+ Add reference
Topics
If your trick fits more than one topic select multiple. Select at least one.
Backend
Plugin Development
CMS
Twig
Themes
Deployment
Tags
You can use existing tags or create new ones. Add at least one.
Submit for review
Cancel
We use cookies to measure the performance of this website. Do you want to accept these cookies?
Accept
Decline