You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We use the renderString method to render a template in the CP context in Sprout Reports Twig Template Reports. This lets us give users the ability to create settings using the Craft CP form macros and stay consistent with the Craft UI.
In a recent release (v3.3.1 it appears) the renderString method now forces the site template mode and doesn't appear to give us a way to override it to set it to the CP template mode.
Create a custom Twig Template using Sprout Reports
Use the {% import "_includes/forms" as forms %} in your settings template, which up until this point let you reference all the Craft form macros for your settings
I haven't run into an issue here yet, and I feel I must be missing how these can be overridden if we wish to use them in the CP context, but it appears the renderObjectTemplate method has also has been updated in a similar way where template mode is being hard-coded to the site context:
Sorry about that, Ben. We started using the Site template mode when those methods are called so people could include their own site templates when they needed more space to work from, for things like entry URI formats, Commerce product SKU formats, etc. I didn’t realize that plugins were already including their own templates internally when calling that method.
I’ve added a new $templateMode argument to each of those methods for the next release, which you can start passing \craft\web\View::TEMPLATE_MODE_CP to, so your own plugin’s templates become available again.
Description
We use the
renderString
method to render a template in the CP context in Sprout Reports Twig Template Reports. This lets us give users the ability to create settings using the Craft CP form macros and stay consistent with the Craft UI.https://github.com/barrelstrength/craft-sprout-reports/blob/v1.2.7/src/datasources/CustomTwigTemplate.php#L127
In a recent release (v3.3.1 it appears) the
renderString
method now forces the site template mode and doesn't appear to give us a way to override it to set it to the CP template mode.https://github.com/craftcms/cms/blob/3.3.6/src/web/View.php#L456
Steps to reproduce
{% import "_includes/forms" as forms %}
in your settings template, which up until this point let you reference all the Craft form macros for your settingsAlso see: https://github.com/barrelstrength/craft-sprout-reports/issues/63
Additional info
The text was updated successfully, but these errors were encountered: