Get admin template in frontend template #944
-
Is it possible to know the selected admin template in the frontend template? We currently have this:
This works, but it will always use the "admin.twig" template. But when I omit the "template" option, the mail isn't sent (is this intentionally or should it fallback to the template selected in the form?) What I'm looking for is an optional override of the "template" option, or a way to get the selected admin template, like this:
But obviously that doesn't work :) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Thanks for your feedback, @FrDH. You might be able to make something like this work by building a custom module (we have something that might get you most of the way there): https://docs.solspace.com/craft/freeform/v4/guides/building-a-custom-module/ Another option might be going about this the opposite way. You could use Twig inside the Admin Notification textarea to insert the recipients from the template. Some steps:
Your template code might look something like this: {{ craft.freeform.form("myForm", {
overrideValues: {
myNewEmailCollectorField: block.adminRecipients|split(',')|map(o => o|trim),
}
}).render() }} Your Admin Notify textarea might look something like this: {% if myNewEmailCollectorField -%}
{{ myNewEmailCollectorField.value }}
{%- else -%}
[email protected]
{%- endif %} https://docs.solspace.com/craft/freeform/v4/guides/passing-dynamic-data-to-forms/ |
Beta Was this translation helpful? Give feedback.
-
Sorry for the late reply, I'll be sure to check this out. Thanks for your time :) |
Beta Was this translation helpful? Give feedback.
-
So the second approach works pretty well (don't know why it wouldn't), too bad the Just a small note for future references:
I'm never sure on how different systems implement a new line (is it with "\n", "\r" or "\n\r"?), but the "\n" seems to work. I also changed the Admin Notify field to this shorter notation: Anyway, thanks a lot for taking the time to figure this out :) |
Beta Was this translation helpful? Give feedback.
Thanks for your feedback, @FrDH.
You might be able to make something like this work by building a custom module (we have something that might get you most of the way there): https://docs.solspace.com/craft/freeform/v4/guides/building-a-custom-module/
Another option might be going about this the opposite way. You could use Twig inside the Admin Notification textarea to insert the recipients from the template. Some steps:
dynamicNotification
feature.block.adminRecipients
.block.adminRecipients
data to Freeform'soverrideValues
parameter.Your template code might look something like this: