News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Requesting Code Help to Remove Post Text from Post Announcements in SMF 2.1

Started by Michael Vail, May 07, 2022, 08:33:22 PM

Previous topic - Next topic

Michael Vail

Hello Everyone,

I requested this as a feature addition to SMF. The request is in the que. In the meantime. I was hoping someone can point me to where I can change the announcement email template for SMF 2.1.1 to remove the text of the post being announced from being sent in the email announcement sent to members. I had long ago figured this out for SMF 2.0 but need help to repeat it in SMF 2.1.1. The only post about it I could find is very outdated and can be found here:

https://www.simplemachines.org/community/index.php?topic=427167.0

A sample of what I'd like the announcement email message to appear like is as follows:

"DO NOT REPLY TO THIS EMAIL NOTICE!

An important topic has been posted and announced in the member area.

You can view and reply to the full topic by following the below link to the member area:

https://www.sonomacountydsa.org/forums/index.php?topic=2658.0

All members are advised to visit the member area at least once per week to stay current on DSA related topics and issues.

Stay safe,
The DSA Team"

If someone could point me to the correct files and areas to make the change, I'd really appreciate it.

Thank you and hope you're having a great weekend!


Kindred

Either edit the English language file or, I believe that 2.1 has an email template editor.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Antechinus

Administration Centre > News and Newsletters > Newsletters ... leads to the email template editor.

davo88

Quote from: KindredI believe that 2.1 has an email template editor.
You can also access it at Admin > Configuration > Languages > Edit Languages > Edit Language Entries > Email Templates
Scroll down to the ones that begin with notification_reply...

Looks like a pretty good tool but I haven't tested it yet.

Sir Osis of Liver

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Michael Vail

Thank you all for the fast replies.

I searched for the email template editor in Administration Centre > News and Newsletters > Newsletters ... as suggested by Antechinus but saw nothing there. If I recall correctly, I may have has a Mod under SMF 2.0 that added that function previously if I recall correctly but don't see it now.

I then followed Davo88's advice to access it at Admin > Configuration > Languages > Edit Languages > Edit Language Entries > Email Templates and found the "new_announcement_body" email template which originally read as follows:

Quote{MESSAGE}


You can view the full announcement by following this link:
{TOPICLINK}

To unsubscribe from these announcements, follow this link:
{UNSUBSCRIBELINK}

For more control over the email notifications you receive, login to the forum and go to the Notifications area in your profile.

{REGARDS}
I edited it as follows:

QuoteDO NOT REPLY TO THIS EMAIL NOTICE!

An important topic has been posted and announced in the member area.

You can view and reply to the full topic in member area by following the below link:

{TOPICLINK}

To limit email spamming, not all posts are announced. As such, all members are highly encouraged to visit the member area at least once per week to stay current on important DSA topics and issues.

Stay safe,
The DSA Team

I then ran a test announcement and having removed the {MESSAGE} section, the announcement displayed exactly as I wanted without the original post content included.

I'll be posting a link to this thread in the feature request thread I started about this so people know where to look thanks to all of you.

Thank you all very much and Happy Mother's Day to you and yours!

Michael Vail

An interesting side note to this. I made my initial edits and saved the template. I went back to edit it again and can no longer change it. Any edits I make are not saved when hitting the save button. I've cleared the forum and my server cache as a precaution and still nothing. I also tried editing the template on a different site I manage. I was able to edit it once, but not again just like the first site.

Any suggestions on why I can't update the template again and the changes aren't being saved? Before I report it as a bug, I wanted to make sure I wasn't missing anything.

Thank you.

Sesquipedalian

Quote from: Michael Vail on May 08, 2022, 05:48:13 PMAn interesting side note to this. I made my initial edits and saved the template. I went back to edit it again and can no longer change it. Any edits I make are not saved when hitting the save button. I've cleared the forum and my server cache as a precaution and still nothing. I also tried editing the template on a different site I manage. I was able to edit it once, but not again just like the first site.

Any suggestions on why I can't update the template again and the changes aren't being saved? Before I report it as a bug, I wanted to make sure I wasn't missing anything.

Thank you.

I cannot reproduce that issue in my tests. More information about your specific circumstances will be required to figure out what is wrong.

1. Did you perform all the previous edits using SMF's language editor, or did you edit the file manually?
2. Have you checked the file permissions on the relevant PHP file?
3. What exactly were the edits that you made? Please tell us both the identifier (e.g. "resend_activate_message_subject") and the exact text of the value for each changed file.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Michael Vail

Good Day Sesquipedalian,

Below are the answers to your questions:

Quote1. Did you perform all the previous edits using SMF's language editor, or did you edit the file manually?
Quote3. What exactly were the edits that you made? Please tell us both the identifier (e.g. "resend_activate_message_subject") and the exact text of the value for each changed file.

I performed the edits by the SMF Language Editor as follows:

1. Logging into the Admin panel of my sites
2. Went to Administration Center>Languages>Edit Languages.
3. Clicked the EDIT button for the default language (English).
4. Used the dropdown menu at the bottom to select Email Templates
5. Scrolled through the templates until locating the "new_announcement_body" template
6. Clicked the EDIT checkbox for that template to enable the text box for editing
7. Replaced the default template text with the following text:

QuoteDO NOT REPLY TO THIS EMAIL NOTICE!

An important topic has been posted in the DSA Member Area.

You can view and reply to the topic in the Member Area: by following the below link to the topic:

{TOPICLINK}

All members are highly encouraged to read these important topics as soon as possible and visit the member area regularly (at least once per week) to stay current on DSA related topics and issues.

Stay safe,
The DSA Team
8. Scrolled to the bottom of the template page and clicked the SAVE button to save the newly formatted template.

I ran a test of the new template by announcing a post to a test usergroup and noticed my edits mistakenly included an extra colon in the body (highlighted in red in the above quote box) so I went through the same steps listed above to  remove the colon and saved the template again. Unfortunately after multiple attempts by repeating the same steps, none subsequent change attempts to the same template would save.

I then went through all of the above on a second similar SMF 2.1.1 site I manage and got the same exact results. 

Quote2. Have you checked the file permissions on the relevant PHP file?

I attempted check the file permission but wasn't exactly sure which file(s) are being changed by the edits so I couldn't confirm the permissions. The only file in the themes/languages folder that had a new date that coincided with the original edits I made was the EmailTemplates.english.php file so it appears Sir Osis of Liver was spot on in his previous post in this thread when he said that is the file tied to the edits. If that is the correct file, its permissions were set by the SMF 2.1.1 installer at 644. I didn't have significant concerns about the file permissions however because I was able to edit the file originally, which indicated the permissions were set ok for editing. Another thing I noticed is the once I made the original changes and successfully changed the file, subsequent saves changed the date and time of the file causing me to believe SMF was able to access the file to save the changes but never actually pushed the changes made on the  the editor screen into the file. 

In order to edit the file correctly, I restored the entire Language folder using the retore tool from my hosting control panel, then followed the same edit procedure to make the changes correctly. As before, the initial edits save fine on the newly restored file, but test attempts to change it again failed to save once the file was edited already.

I hope this helps you and appreciate the reply and assistance.

Take care.

Antechinus

Just FYI: your post would be a lot easier to read if you didn't mess with font and colours. I'm curious about the topic, but I'm running a dark theme override here, and most of your colour choices are near to illegible for me. I had to disable all your formatting in my document inspector to make the post easy to read. :)

Sesquipedalian

Those answers are very helpful, yes.

Based on this description, it sounds like something is causing the file permissions on the EmailTemplates.english.php to change after the PHP process updates it. That is very odd, since if PHP had the ability to write to the file the first time, it should continue to have that ability on subsequent attempts. This leads me to suspect that some other process on your server is changing the file permissions while PHP isn't looking. Some hosts do that sort of thing if, say, a security algorithm thinks a recent change looks suspicious for whatever reason.

If I a correct, then there isn't much that we can do about it from within SMF. You can try to find out what is caused the file permissions to change unexpectedly like that, or you can just decide to manually restore PHP's write access to the file before you make subsequent edits.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Michael Vail

Sorry Antechinus, when pasting things into the post editor from other places here, the font's get mixed up or change color so when I finished my last post, I highlighted all the text set all the text to be basic size, black 2 arial font thinking it would be easy to read. To me, it looks almost identical to what it looks like without changing it. It looks perfectly legible to me using the default theme here. I had no idea it screwed things up for others. In the future I'll try to limit the copy-pasting to avoid formatting issues. I've had problems with formatting posts, especially in quoted areas using the new editor in SMF 2.1, especially when using the quick-reply box. Thanks for letting me know.

Michael Vail

Thank you very much that Sesquipedalian, I'll contact my host about this and report back as to what I found out to close the loop. 

Have a great day!

Michael Vail

So just a quick follow-up. The host denied this has anything to do with their system.

I opened the Email.Templates.english.php file via Notepad++ though a Filezilla FTP connection. I manually changed the section I had edited previously and saved it back to the server by overwriting the previously saved version and had no problems.

I returned to the SMF template editor pulled up the template and saw that it correctly displayed the changes I just made with Notepad++. I used the SMF language editor to make changes to the template again and the edits saved. I then went in to the SMF language editor and tried to change it again and it wouldn't save again. SO BIZARRE! Why won't the SMF editor allow me to edit a template more than once! SMF is saving the file when I save it with the editor, it's just not pushing the changes into the file after it does it the first time. I'm starting to think this may be some problem with the SMF cache system but I emptied that cache both through the Admin panel feature and manually by emptying the cache folder and it didn't fix anything. 


Sesquipedalian

Quote from: Michael Vail on May 09, 2022, 06:15:48 PMWhy won't the SMF editor allow me to edit a template more than once

Well, as I said, SMF itself isn't preventing that. SMF simply writes the updated data to the file, and does nothing at all regarding the file permissions after it does so. You can even see this for yourself right here; we just save the data to the file using PHP's simple file_put_contents() function, and that's it. No permissions changes are made.

I don't doubt for a moment that the file permissions are in fact being changed for some reason on your server. But I can't tell you why that's happening, because they don't get changed on other servers and SMF itself never tries to change them.

I strongly doubt the cache system is causing this. The cache never does anything with the file permissions on the standard files.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Michael Vail

The reason I'm struggling with this is being a permissions issue is because no matter what I set the permissions of the file to, even at 777, the file's contents aren't being changed by SMF after the first time the SMF language editor accesses and changes it. However, if I replace the file with copy via FTP transfer and then edit it with the language editor, SMF successfully changes it the first time and then can't again. It's like the copy made by SMF's editor is no longer editable by SMF after its done one time. The permissions never change when SMF uploads a fresh copy, at least according to FileZilla and the hosting control panel's file manager.

What appears to be happening is SMF simply keeps uploading copy of the unchanged file to the server after the initial changes have been made. I can see the file's date and timestamp change so I know at least the file is being uploaded but obviously SMF isn't changing anything in the file. So I just don't see how the permissions of the file can be problem? I'm sorry if I'm missing something, I just don't get it.

Just out of curiosity, do you have an SMF 2.1.1 or 2.1.2 forum you can use as a test bed to attempt multiple changes to the same template file the way I did and see if you can change it more than one time using the SMF Language editor?

Sesquipedalian

I did test that, yes. Saved every time.

If the file is still writable after it has been edited, but nevertheless isn't being updated, then something else is going on. I'm not sure what that might be yet, because I can't reproduce the problem in my own tests.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Michael Vail

Thank you my friend. I know you're plenty busy and if it's working for you, then it's probably specific to something on my end. Please don't waste any more time on it. Other people need your help more than I do. I'll keep playing with it and update the thread if I figure it out. I really appreciate your time. 

Have a great week!

Advertisement: