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.
Inspired by the following October trick from OFFLINE: [Render an e-mail template in the browser](https://octobertricks.com/tricks/render-an-e-mail-template-in-the-browser) The following code allows you to programatically render an email template. You can place this within your controller, or as the response to a route, or as a variable for a page or layout template. ```php // Within your use cases use System\Classes\MailManager; use System\Models\MailLayout; use System\Models\MailTemplate; // The code $data = [ 'key' => 'value', 'foo' => 'bar', ]; $layout = new MailLayout; $layout->fillFromCode('default'); // Change this to use another layout. $template = new MailTemplate; $template->layout = $layout; $template->fillFromView('winter.plugin::mail.templates.your-template'); // Use the mail template code here. $mailContent = MailManager::instance()->renderTemplate($template, $data); ```
References
Add additional online resources to your trick
×
Name
URL
+ 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