I am fairly new to Umbraco so some of the things I say might seem very basic to you.
I have an Umbraco Surface Controller (MemberSurfaceController.cs). I like having my controllers light, so I want them simply calling "services" that deal with the logic and processes that need to happen. The service used by my Surface Controller is (LslMemberService.cs). Here's what that looks like:
namespace LSLUmbraco.Services.Implementations
{
// various using statements
public class LslMemberService : ILslMemberService
{
private readonly ICustomerService _customerService;
private readonly ISystemService _systemStatusService;
private readonly IMemberService _memberService;
private readonly IEmailService _emailService;
private readonly MembershipHelper _membershipHelper;
public LslMemberService(ISystemService systemStatusService, ICustomerService customerService, IEmailService emailService)
{
_systemStatusService = systemStatusService;
_customerService = customerService;
_emailService = emailService;
_memberService = ApplicationContext.Current.Services.MemberService;
_membershipHelper = new MembershipHelper(UmbracoContext.Current);
}
// other code omitted
private string BuildEmailBody(string emailAddress, string verificationToken)
{
var emailBody = // need to grab email template from field in Umbraco
return emailBody;
}
}
}
Not sure if you noticed, but in my method BuildEmailBody(params) I would like to grab the email template from Umbraco.
I'm not sure what the technical Umbraco term is, but I call them Umbraco Fields. I have an Umbraco field of type rich text editor where the Admin of the site can set his/her email template.
My question is, how do I grab that Umbraco field from my LslMemberService?
Umbraco Fields outside of Surface Controller?
Hello everyone
I am fairly new to Umbraco so some of the things I say might seem very basic to you.
I have an Umbraco Surface Controller (MemberSurfaceController.cs). I like having my controllers light, so I want them simply calling "services" that deal with the logic and processes that need to happen. The service used by my Surface Controller is (LslMemberService.cs). Here's what that looks like:
Not sure if you noticed, but in my method BuildEmailBody(params) I would like to grab the email template from Umbraco.
I'm not sure what the technical Umbraco term is, but I call them Umbraco Fields. I have an Umbraco field of type rich text editor where the Admin of the site can set his/her email template.
My question is, how do I grab that Umbraco field from my LslMemberService?
Any help would be greatly appreciated.
Hi Ciwan,
A few questions ?
What is the document type alias of the "register page" ?
Are you using modelsbuilder ?
Dave
Hi Dave
Do you mean this?
Hi Ciwan,
This is exactly what i meant.
So in your service you can do this :
This assumes you have only one page of this type in your website.
Once you have that you can do this to get the field with the mail body :
That will give you the mail body field
Dave
Thanks Dave, I tried as suggested, but it seems like that first line isn't finding it! The registrationPage is null.
Hi Ciwan,
Can you try this
UmbracoContext.Current.ContentCache.GetSingleByXPath("//registration[@isDoc]");
Maybe I made a error in the casing.
Dave
Hi Ciwan,
Did my last comment work for you ?
Dave
Thanks Dave, I believe it did. :)
Nice to hear that.
Dave
is working on a reply...