having email notification contain post body?

Get help with installation and running phpBB 3.0.x here. Please do not post bug reports, feature requests, or MOD-related questions here.
Get Involved
Forum rules
END OF SUPPORT: 1 January 2017 (announcement)
User avatar
VPWanda
Registered User
Posts: 15
Joined: Tue Mar 07, 2006 12:08 am

Re: having email notification contain post body?

Post by VPWanda »

fpbaum wrote:You have to change the email templates as well as add some code to insert the post message into the templates. The email templates are just text files with place holders that get dynamically replaced with stuff like the forum name, post subject, etc...so you just have to create a new place holder, in your case "{POST_TEXT}" and then fill it.
....
I made the changes and it works.
However, it doesn't look very nice when smilies or quotes are used.
Is there anyway to clean up the post text?

I would also love the name of the poster included in the notification.

If you can help me with that, I would really appreciate it!
fpbaum
Registered User
Posts: 52
Joined: Mon Aug 20, 2007 10:53 pm

Re: having email notification contain post body?

Post by fpbaum »

i didn't pay much attention to massaging the bbcode since it's mostly fluff...the message is there and if they want it to look pretty i'd rather they visit the forum.

Smilies are sent as their text equivalent, so :D = colon + D, and quotes are sent just as the quoted text...that's about as clean as it gets. It looks like emails are only sent as text/plain (no html) so there isnt' much more you can do unless you want to fix the messenger class code to send html...not trivial. :o

What really doesn't work is url image bbcode tags. Colons and periods are encoded...no idea why.

Adding poster name...The global $user is already defined at the top of functions_posting.php->function user_notification(), so you can add...

Code: Select all

'POSTERNAME'		=> htmlspecialchars_decode($user->data['username']),
...to the assign_vars() call and then add "{POSTERNAME} wrote..." to the email templates.
User avatar
VPWanda
Registered User
Posts: 15
Joined: Tue Mar 07, 2006 12:08 am

Re: having email notification contain post body?

Post by VPWanda »

fpbaum wrote:Smilies are sent as their text equivalent, so :D = colon + D
I could definitely live with that, but I was getting full links to the smilie gifs pictures.
Do you have any idea why that's happening to me?

I think I just figured it out myself.
Not only did I upgrade to phpbb3, I also switched servers.
I don't see the smilies in any directory on this server, so I'm guessing it's getting them from the old server.
That would explain it.

I'm sure it will work once I move the smilies over.
Thanks a lot for the help and also the poster name!
I'm still very new to all of this, but am already proud I managed to switch servers and upgrade the software without too many problems.
fpbaum
Registered User
Posts: 52
Joined: Mon Aug 20, 2007 10:53 pm

Re: having email notification contain post body?

Post by fpbaum »

hmm, that doesn't sound right. IJust checked...I've made changes since the original post, probably important :? . Try this instead of the previous code in functions_posting.php...

Code: Select all

//remove bbcode from text
$stripped_post_text = $data['message'];
strip_bbcode($stripped_post_text, $data['bbcode_uid']);
user_notification($mode, $subject, $data['topic_title'], $data['forum_name'], $data['forum_id'], $data['topic_id'], $data['post_id'], $stripped_post_text);       
User avatar
VPWanda
Registered User
Posts: 15
Joined: Tue Mar 07, 2006 12:08 am

Re: having email notification contain post body?

Post by VPWanda »

The username works. Thanks a lot!

However, I'm still having a problem with the smilies.
I moved them over to the new server, but apparently that wasn't the problem.

I'm getting notified of the message:
testing :)
as follows:
testing <!-- s:) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":)"
title="Smile" /><!-- s:) -->

If you could help me with this, I would be very grateful!
fpbaum
Registered User
Posts: 52
Joined: Mon Aug 20, 2007 10:53 pm

Re: having email notification contain post body?

Post by fpbaum »

Did you try the above change?
User avatar
VPWanda
Registered User
Posts: 15
Joined: Tue Mar 07, 2006 12:08 am

Re: having email notification contain post body?

Post by VPWanda »

fpbaum wrote:Did you try the above change?
Yes, I had put the remove bbcode in there.

----

Okay, I got it to work.
My stupid mistake.
I had put the remove bbcode in there, but still passed the post_text instead of the stripped_post_text into the notification method.

Everything works great now.
Thanks a lot!
fidelmty
Registered User
Posts: 4
Joined: Tue Apr 01, 2008 6:42 pm

Re: having email notification contain post body?

Post by fidelmty »

fpbaum wrote:

Code: Select all

//remove bbcode from text
strip_bbcode($stripped_post_text, $data['bbcode_uid']);
 
i, am newbie and use the original post and work fine, except for the bbcode, i'm not shure where this line of code is located or wath code replace..

Thanks
fpbaum
Registered User
Posts: 52
Joined: Mon Aug 20, 2007 10:53 pm

Re: having email notification contain post body?

Post by fpbaum »

These lines...

Code: Select all

//remove bbcode from text
$stripped_post_text = $data['message'];
strip_bbcode($stripped_post_text, $data['bbcode_uid']);
...are new. They go before the call to user_notification and $stripped_post_text is passed to user_notification.
fidelmty
Registered User
Posts: 4
Joined: Tue Apr 01, 2008 6:42 pm

Re: having email notification contain post body?

Post by fidelmty »

thanks, works great....
MsIrey
Registered User
Posts: 144
Joined: Tue Sep 02, 2008 1:50 am
Location: Florida

Re: having email notification contain post body?

Post by MsIrey »

Does this mod work in version 3.02?
fpbaum
Registered User
Posts: 52
Joined: Mon Aug 20, 2007 10:53 pm

Re: having email notification contain post body?

Post by fpbaum »

I'd imagine yes, though I haven't upgraded yet so I can't say for sure. The changes are pretty basic so you could easily adapt it.
drwharris
Registered User
Posts: 7
Joined: Mon Sep 15, 2008 12:41 pm

Re: having email notification contain post body?

Post by drwharris »

First off I would like to say a big thank you. But also as an FYI you dont have to have the " marks around the {POST_TEXT}.

And yes it works on 3.0.2.

Cheers

Andrew
fpbaum
Registered User
Posts: 52
Joined: Mon Aug 20, 2007 10:53 pm

Re: having email notification contain post body?

Post by fpbaum »

True, the quotation marks are fixed text that gets displayed in the email message.
maorc
Registered User
Posts: 1
Joined: Sat Sep 27, 2008 7:50 pm

Re: having email notification contain post body?

Post by maorc »

Any advantage of applying the changes suggested above over the Prime Notify mod:
http://www.phpbb.com/community/viewtopi ... 15&start=0
:?:
Locked

Return to “[3.0.x] Support Forum”