Email Template Editor

Started by Matthew K., March 31, 2011, 10:56:52 PM

Previous topic - Next topic

fairchilde

That makes perfect sense, and should be easy to manipulate. Is there a location or file that I should be looking for the existing str_replace and add this one to? I searched through the files on my host and couldn't find any instances where it was used. Any follow up recommendations?

Matthew K.

Well, if you parse the mod on the mod site, or look in the package, you'll be able to find all of Email Template Editors code, which would also have the str_replace(); be it in an edit, or in a file, it'd be there. Most likely, when I wrote this...I put it in a direct modification, and not it's own file. Which would make it easier to track for you, actually. But not as good of a practice overall.

Let's go ahead and parse it...Email Template Editor, select 2.0 RC5 from the compatibility list on the right, and then click Parse. Hmm, I don't see any str_replace();'s. So that must mean it's in an Email Template Editor file. So, we'll download the .zip, extract the archive, and open "EmailTemplateEditor.php".

Lines 73-81:
Code (Global Preset Variables) Select
// Global Pre-Set Variables...
$context['email_templates']['preset_variables']['global'] = array(
'forumname' => '{FORUMNAME}',
'scripturl' => '{SCRIPTURL}',
'themeurl' => '{THEMEURL}',
'imagesurl' => '{IMAGESURL}',
'default_themeurl' => '{DEFAULT_THEMEURL}',
'regards' => '{REGARDS}'
);

Actually, it's quite surprising how well I wrote this for how long ago it was.

Hope this helps!
Have a fantastic day!

fairchilde

you sir. you are a super hero! ;) have a great day!

Matthew K.

Haha thank you, and you as well!

littlenicki

Hello could this mod be backported to SMF 1.1 please? Thank you
Fomer SMF user. Switched to Invision Power Board and VBulletin

Matthew K.

Nope, this modification will not be ported back to SMF 1.1.x. Unless someone were wanting it badly enough to make a reasonable donation, then I'd consider it.

FireDitto

Hey guys; Installed and works great, but I do have a question.

The email it brought up when I first asked it to let me edit came in with a lot of {DESCRIPTION's} that didn't phase through into links and so such, such as: {USERNAME}, {FORGOTPASSWORDLINK}, {ACTIVATIONLINK}, {ACTIVATIONLINKWITHOUTCODE} and {ACTIVATION CODE}

I'm happy to manually add them, or whatever, but... I have no idea how to go about it. I mean, I see your code quote above, pointing out where the ones that worked are, but how do I know which bit is relevant for the information I don't have?

Thank you :)
Second Pass Weyr<br />An AU Pernse RPG<br /><br />SMF 2.0.6 with SP 2.3.5

Matthew K.

Those "quick variables" will only work in certain email templates that already parse them.

FireDitto

Oh.

How would I go about making them work now? Can I make them 'global'?
Second Pass Weyr<br />An AU Pernse RPG<br /><br />SMF 2.0.6 with SP 2.3.5

Matthew K.

To make a "global preset variable" or whatever I call them in this modification, you'd need to write some sort of str_replace(); that actually replaced the "text" with the substance you expect. For instance...$string = '{scripturl}' -> str_replace('{scripturl}', $scripturl, $string);

If the data is not in an existing variable, you have to retrieve it somehow with a query or what not, so it can definitely get more complicated depending on what you are trying to access. What is your goal here?

FireDitto

I think I understood that, lol. I need to go to bed, so I'll re-read that and make sense of it in the morning.

Namely, to make whatever crops up in the default email style work as it was intended to; I just want to easily edit the flowery text around the needed information. So that would be those above, and whatever others crop up in the other email templates, I expect.
Second Pass Weyr<br />An AU Pernse RPG<br /><br />SMF 2.0.6 with SP 2.3.5

Arantor

As a suggestion, would it not be worth taking the time to go through the email templates, finding out what variables they use (not just what they claim to use, but what the source actually exposes to the email loader), and providing that as a list to users?

I've been doing that today and I've gone through all the templates, figuring out what's available, it's pretty dull to backtrace everything though ;) I did also harmonise some stuff, for consistency as well as provide a description to users of when each email will be sent.

When I first saw the mod, I actually thought the list on the left were actually a set of buttons that one could click to have the variable inserted directly into the body, like bbcode etc. is in the main editor normally. Might be another nice feature to add.

It certainly would be a great addition to 2.1 and I see no reason at all not to include it as a core feature (you're a developer, just implement it and worry about complaints later, hahah). I'd also be inclined to move it to Admin > Maintenance > Mail as a subitem rather than in the main area, though. Keeps all the mail stuff together.

If it does get added, spending the extra day to collate all the information is really worth it IMHO.(Screenshot attached for what it can look like. I suck at UI.)

Matthew K.

Hey Arantor!

Thank you for providing your thoughts, and I'll definitely consider it. Also nice to see what you've come up with for Wedge, looks pretty cool.

Best Regards

Matthew K.

I will be rewriting this modification when SMF hits 2.1.

kdmiller45

Will this editor be modified to work with version 2.04 in the near future, sound like what I need, but will not install with smg 2.04.

Colin

Do you mean 2.0.4? It should work.
"If everybody is thinking alike, then somebody is not thinking." - Gen. George S. Patton Jr.

Colin

Matthew K.

Yeah, I've used this on SMF 2.0.4. :P No absolute promises though.

Colin

What error are you getting?
"If everybody is thinking alike, then somebody is not thinking." - Gen. George S. Patton Jr.

Colin

srs

Does this work on SMF version 2.0.4 ?

Colin

"If everybody is thinking alike, then somebody is not thinking." - Gen. George S. Patton Jr.

Colin

Advertisement: