diff --git a/026-How-to-setup-a-store-message-method-along-side-the-email-helper-class.md b/026-How-to-setup-a-store-message-method-along-side-the-email-helper-class.md index f4cef94..edcfa50 100644 --- a/026-How-to-setup-a-store-message-method-along-side-the-email-helper-class.md +++ b/026-How-to-setup-a-store-message-method-along-side-the-email-helper-class.md @@ -1 +1,15 @@ -Hi I've already done a tutorial how to use the email helper in your components And in that tutorial I actually do touch upon The storing of messages Or emails for that matter Once it's been sent Now I would like to just look at that again For those of you that may just be wanting to know that [00:00:24](https://www.youtube.com/watch?v=peVNLsAncGY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m24s) So Obviously at this stage you should know That the email helper class it basically added to the helper folder Of your components backend So and it's usually called your components name and then email That's that's the email helper class so to use it In the custom script you could use the 3 braces brackets Is that ok and then component like that And then just email [00:00:59](https://www.youtube.com/watch?v=peVNLsAncGY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m59s) And sent And That is how you would basically construct Your Your script I show that as well in the tutorial We we going to more depths of how to use the email helper But At the very bottom of this class in the send Method [00:01:21](https://www.youtube.com/watch?v=peVNLsAncGY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m21s) There is a little snippet quite its significant as it may seem Actually gives you a very great Ability Because The result Of the email that was sent Is placed in send email This result is passed to the method as well The first it looks in your helper class [00:01:47](https://www.youtube.com/watch?v=peVNLsAncGY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m47s) Which is usually a component name Helper That's the helper class And whether this method exists in that class And this method will not exist unless you Write it So The area where you would have to write this method Is in the component there is an area Called [00:02:13](https://www.youtube.com/watch?v=peVNLsAncGY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m13s) Admin helper Let's look at that So we open a component We go to libraries and helpers we scroll down And we see there is Email helper And then underneath it helper admin class And it's in this area that you need to add that method Now I realized I've chosen the wrong components so this component actually does not use that storage concept [00:02:47](https://www.youtube.com/watch?v=peVNLsAncGY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m47s) But there is another one that does let's open that one instead then So again we are in Helper admin class And we have a function called Store message and this is in the components That where you edit your component So this store message has what we call a signature Values that it is passing to the method And in the The [00:03:19](https://www.youtube.com/watch?v=peVNLsAncGY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m19s) Email helper class You see that it Also has A signature But wherever it gives this = with a value That means that that's the default value so if you do not add A value for this position there is one two three four fifth position Then it will default to 0 if we do not add this it will default to null So From there all the way to the end all of those values haves basically the [00:03:51](https://www.youtube.com/watch?v=peVNLsAncGY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m51s) Null value So In reality you only need to add you know these values the first four But Those values are all used in this method So if you wanna understand exactly how these value should look look inside of the method Read through the method And you will see So Making a long story short [00:04:17](https://www.youtube.com/watch?v=peVNLsAncGY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m17s) We end up here at this little script Basically ask whether you created the method or not If you didn't it simple skips it and returns the value of send mail if it sees That you have created it It'll pass these variables that correspond to the signature And then inside of that method that is in your helper class That is now this method You need to do the necessary checks and balances And discovering For example since you've got the email address [00:04:52](https://www.youtube.com/watch?v=peVNLsAncGY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m52s) You can Search with the getVar In the user class It must equal Email Recipient = email And then returns to us the ID So [00:05:09](https://www.youtube.com/watch?v=peVNLsAncGY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m09s) That is basically how the getVar works And Then when we have the user ID We can obviously make sure it's The number and we set it to our message as user And we set it as the email and now we can store The message in whatever table or do whatever we wanna do Beyond The normal So even if you wanna do other things except [00:05:38](https://www.youtube.com/watch?v=peVNLsAncGY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m38s) Storing the message This is the method inside of which you can do it so store message Is the method inside which you can do some more custom scripting On top of your email integration Ok so that's just quickly giving a little bit more depth on that specific aspect Of using The email class in your component Thank you for watching +# HOW TO SETUP A STORE MESSAGE METHOD ALONG SIDE THE EMAIL HELPER CLASS + +* ### Example In Code + +Hi, I've already done a tutorial how to use the email helper in your components. In that tutorial I actually do touch upon the storing of messages. Or emails for that matter once it's been sent. I would like to look at that again. For those of you that may just be wanting to know. [00:00:24](https://www.youtube.com/watch?v=peVNLsAncGY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m24s) At this stage you should know that the email helper class is added to the helper folder of your components back end. It's usually called your components name and then email, that's the email helper class. To use it in the custom script you could use the 3 brackets '[[[component]]]email' and send. [00:00:59](https://www.youtube.com/watch?v=peVNLsAncGY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m59s) That is how you would construct your script. I will show that as well in the tutorial as we going to in more depths of how to use the email helper. + +### Code Snippet In Method + +At the very bottom of this class in the send method, [00:01:21](https://www.youtube.com/watch?v=peVNLsAncGY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m21s) there is a little snippet, it is quite significant as it may seem, it actually gives you a great ability. Because the result of the email that was sent is placed in sendemail. This result is passed to the method as well. First it looks in your helper class [00:01:47](https://www.youtube.com/watch?v=peVNLsAncGY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m47s) which is usually a component name, helper, that's the helper class whether this method exists in that class. This method will not exist unless you write it. The area where you would have to write this method, is in the component. There is an area called [00:02:13](https://www.youtube.com/watch?v=peVNLsAncGY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m13s) admin helper. + +### Adding Code To Admin Helper Area + +We open a component. We go to libraries and helpers. We scroll down. We see there is email helper. Then underneath it, helper admin class. And it's in this(php) area that you need to add that method. Now I realized I've chosen the wrong components. This component actually does not use that storage concept, [00:02:47](https://www.youtube.com/watch?v=peVNLsAncGY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m47s) but there is another one that does. Let's open that one instead then. So again we are in helper admin class, we have a function called storemessage, and this is in the components, where you edit your component. Storemessage has a signature. Values that it is passing to the method. In the [00:03:19](https://www.youtube.com/watch?v=peVNLsAncGY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m19s) email helper class, you will see that it also has a signature. Wherever it gives this '=null' with a value, that is the default value. If you do not add a value for this position, there is one, two, three, four, fifth, positions, then it will default it to 0, if we do not add this, it will default to null. From there all the way to the end all of those values have the [00:03:51](https://www.youtube.com/watch?v=peVNLsAncGY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m51s) null value. In reality you only need to add the first four values. Those values are all used in this method(see video). If you want to understand exactly how these value should look, look inside of the method, read through the method, and you will see. + +Making a long story short, [00:04:17](https://www.youtube.com/watch?v=peVNLsAncGY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m17s) we end up here at this little script. Basically ask whether you created the method or not. If you didn't it simple skips it and returns the value of send mail. If it sees that you have created it, it'll pass these variables that correspond to the signature. And then inside of that method that is in your helper class, that is how this method, you need to do the necessary checks and balances, and discovering for example since you've got the email address. [00:04:52](https://www.youtube.com/watch?v=peVNLsAncGY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m52s) You can search with the getVar in the user class. It must equal email, recipient equal email, and then returns to us the id. So [00:05:09](https://www.youtube.com/watch?v=peVNLsAncGY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m09s) That is basically how the getVar works. Then when we have the user id, we can make sure it's the number and we set it to our message as user. We set it as the email. Now we can store the message in whatever table or do whatever we want to do beyond the normal. Even if you want to do other things except [00:05:38](https://www.youtube.com/watch?v=peVNLsAncGY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m38s) storing the message. This is the method inside of which you can do it. Storemessage is the method inside which you can do some more custom scripting on top of your email integration. That's just quickly giving a little bit more depth on that specific aspect of using the email class in your component. \ No newline at end of file