News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Add board title to notification e-mail

Started by bonnie_lass, April 10, 2017, 10:42:13 AM

Previous topic - Next topic

bonnie_lass

I would like to add board title to subject in notification e-mail.

I've been looking at the code for the email and the $replacement section:


$replacements = array(
'TOPICSUBJECT' => $topicData[$key]['subject'],
'TOPICLINK' => $scripturl . '?topic=' . $topicData[$key]['topic'] . '.new#new',
'MESSAGE' => $topicData[$key]['body'],
'UNSUBSCRIBELINK' => $scripturl . '?action=notifyboard;board=' . $topicData[$key]['board'] . '.0',
);

Where does the $topicData[$key] come from and how can I add something like $topicData[$key][boardtitle] to get the board title of the topicsubject? Any help to get me in the right direction would be appreciated.

MobileCS

#1
This should do the trick ...

** NOT TESTED **

Sources/Subs-Post.php

Find:
function sendNotifications($topics, $type, $exclude = array(), $members_only = array())
{
global $txt, $scripturl, $language, $user_info;
global $modSettings, $sourcedir, $context, $smcFunc;


Add After :
global $board_info;


Find:
'TOPICSUBJECT' => $topicData[$row['id_topic']]['subject'],

Replace:
'TOPICSUBJECT' => $board_info['name'] . ' - ' . $topicData[$row['id_topic']]['subject'],

bonnie_lass

Thank you for your help, unfortunately it doesn't work. After trying a couple of times I realized the changes must be made in the file Source/Post.php not Subs-Post.php. When I implemented the code in Post.php I at least got the dash between to show but not the the board name. I've tried $board_info['name'], $context['page_title'] etc and I can't get anything to show. Any clue as to how to get the board title in there?

bonnie_lass

Solved it! I had forgotten to add $board_info in global (in file Sources/Post.php), see below:

// Notify members of a new post.
function notifyMembersBoard(&$topicData)
{
global $txt, $scripturl, $language, $user_info;
global $modSettings, $sourcedir, $board, [b]$board_info, [/b]$smcFunc, $context;


Thanks for your help MobileCS, it got me in the right direction!

Advertisement: