I created a workflow using umbraco and what I am trying to do is:
create a workflow that get the html created by a razor template (umbraco.forms).
Here is the locations where is the templates of umbraco.forms
Views\Partials\Forms\Emails
This template is what I want to send by email when this workflow is called.
public class SendMail : WorkflowType
{
//Here I get the path where the razor template is
[Umbraco.Forms.Core.Attributes.Setting("Path to template",
Description = "Path to template",
View = "TextField")]
public string Template{ get; set; }
public SendMail()
{
this.Id = new Guid("ccbeb0d5-adaa-4729-8b4c-4bb439dc0204");
this.Name = "Send Mail";
this.Description = "Send Mail";
this.Icon = "icon-plugin";
this.Group = "Services";
}
//When workflow get called this method is executed
public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)
{
//here I'm trying to get the template converted to string however isn't work
// string template = html.Raw(Template).ToString();
}
}
I tried string template = html.Raw(Template); but I have no access to the html.Raw("");
I've tried this solutions but seems that record.ParseWithRazorView(filePath); doesn't exists
There is a workflow that do something close but seems I can't re-write or get access to this code
namespace name.Core.Controllers
{
public class TemplateController : Umbraco.Web.Mvc.SurfaceController
{
public ActionResult Template()
{
return View();
}
}
}
The I pass the URL into "pathtoTemplate"
public static class TemplateHTML
{
public static string GetTemplate(string pathtoTemplate)
{
using (WebClient client = new WebClient())
{
var encodingbody = client.DownloadData(CaminhoTemplate);
return Encoding.UTF8.GetString(encodingbody);
}
}
}
var body = TemplateHTML.GetTemplate("http://example.com/umbraco/surface/Template/Template")
How to get html generated by razor into a string?
I created a workflow using umbraco and what I am trying to do is: create a workflow that get the html created by a razor template (
umbraco.forms
).Here is the locations where is the templates of
umbraco.forms
I tried
string template = html.Raw(Template);
but I have no access to thehtml.Raw("");
I've tried this solutions but seems that
record.ParseWithRazorView(filePath);
doesn't existsThere is a workflow that do something close but seems I can't re-write or get access to this code
Hi Amadeu,
You can get the template to string by calling this code. You don't require Html.Raw here.
Regards,
Shaishav
Hi Shaishav Karnani,
Seems that I can't find the method ReadAllText()
Hi Amadeu,
have you referenced the namespace System.IO?
~ Jonathan
I created a View and a umbraco controller
The I pass the URL into "pathtoTemplate"
is working on a reply...