News:

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

Main Menu

Need to change signature of Announce Topic (99% there!)

Started by sumocomputers, July 13, 2007, 02:58:10 PM

Previous topic - Next topic

sumocomputers

SMF Version: SMF 1.1.3
My goal is simple.  When a specific user (we will call him Bob), announces a topic he created, the email that everyone gets should say Regards, Bob.  Currently it says Regards, [Name_of_Forum] Team.

Sorry if this has been asked before, I searched and could not find what I was looking for.

I poked around on my own and finally figured out (I think), what file needs to change, but not sure the value to put in.


In Post.english.php line 9:

$txt[130] = "Regards,\nThe " . $context['forum_name'] . ' Team.';

I know I need to replace 'forum_name' with ???  My guess is 'member_name', but wasn't sure, and would be grateful to know where the list of those variables is kept, so in the future I can figure it out on my own without bothering you guys here.

I want to make sure that it is the member who had created the topic, not just any moderator or admin who might modify the post and check the box "Announce Topic".

Thanks


Chris

sumocomputers

Just an update.

I tried replacing 'forum_name' with member, member_name, member.name, user, user_name, user.name.

No joy so far.

I guess I keep trying and searching...

Thanks

tam2oo5

is it not something like {NAME} or something.  How is the signature exactly layed out mate?

sumocomputers

Quote from: tam2oo5 on July 13, 2007, 07:21:27 PM
is it not something like {NAME} or something.  How is the signature exactly layed out mate?

Not sure I exactly understand the question, but...

Currently the default signature in the received email says:

Regards,
Name of Forum Team.


In Post.english.php looking at line 9 I see:

$txt[130] = "Regards,\nThe " . $context['forum_name'] . ' Team.';

So I know I need to change at least ['forum_name'] to something else so that the announcement appears as though it is coming from the user who started (and probably announced) the topic.  I just don't know what to put in there...

Thanks


Chris

tam2oo5

Did you try ['NAME'] , or {NAME} . This code usually replaces the NAME function with the username. Its worth a try , its what i use when i PM my user's.

sumocomputers

Quote from: tam2oo5 on July 14, 2007, 10:40:57 AM
Did you try ['NAME'] , or {NAME} . This code usually replaces the NAME function with the username. Its worth a try , its what i use when i PM my user's.

Tried both, still shows up in the error log as unknown index, and the username is not inserted on the received email.

At this point I am just guessing, but I know someone out there knows the answer.

Also, is this even the right child board?

metallica48423

Try $context['user']['name']

If that doesn't work, i'm clueless
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

sumocomputers

Quote from: metallica48423 on July 15, 2007, 12:37:19 AM
Try $context['user']['name']

If that doesn't work, i'm clueless

That did it!  Thank you very much.  Not sure why ['user'] alone did not work...

Here is a small issue, not sure if it can be resolved.  If user Bob creates the post and announces it, the message goes out with the signature of "Bob".  OK Great.

But if an admin modifies the post for example, the new email goes out with the signature of "Admin".  Not so good.  I would really like it to always use the username of the creator of the post.  Hope that makes sense.

Thanks

metallica48423

Hmm...  I doubt this will work but its worth a shot.

$topic['first_post']['member']['link']

Otherwise, i haven't a clue
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

sumocomputers

Quote from: metallica48423 on July 15, 2007, 03:24:34 AM
Hmm...  I doubt this will work but its worth a shot.

$topic['first_post']['member']['link']

Otherwise, i haven't a clue


Well, doesn't work. I get Undefined variable: topic in my error log.

I still appreciate the help, as your first solution is good enough for now.

codenaught

You can change that line to something like:

$txt[130] = "Regards,\n " . (!empty($context['topic_subject']) ? $context['topic_subject'] : 'The ' . $context['forum_name'] . ' Team.') . "";

So in other words, $context['topic_subject'] is the one you would want, but I would add a test like I did above because it probably won't always be defined when the string is used.
Dev Consultant
Former SMF Doc Coordinator

sumocomputers

Quote from: akabugeyes on July 15, 2007, 12:19:06 PM
You can change that line to something like:

$txt[130] = "Regards,\n " . (!empty($context['topic_subject']) ? $context['topic_subject'] : 'The ' . $context['forum_name'] . ' Team.') . "";

So in other words, $context['topic_subject'] is the one you would want, but I would add a test like I did above because it probably won't always be defined when the string is used.

OK, I will try this, but will this insert the name of the creator of the post being announced?  That is what I am really after.

codenaught

Wow, actually this wouldn't work. It would get only the topic subject. I think I misread the subject bit, thinking it said starter.

Give me a few minutes, and I will try to get an answer for you.
Dev Consultant
Former SMF Doc Coordinator

codenaught

Okay, sorry for all the confusion. After taking a closer look, this probably would be the best way to do this:

In Sources/Post.php:

// Get the topic subject and censor it.
$request = db_query("
SELECT m.ID_MSG, m.subject, m.body
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t)
WHERE t.ID_TOPIC = $topic
AND m.ID_MSG = t.ID_FIRST_MSG", __FILE__, __LINE__);
list ($ID_MSG, $context['topic_subject'], $message) = mysql_fetch_row($request);


Chang to:

// Get the topic subject and censor it.
$request = db_query("
SELECT m.ID_MSG, m.subject, m.body, m.posterName
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t)
WHERE t.ID_TOPIC = $topic
AND m.ID_MSG = t.ID_FIRST_MSG", __FILE__, __LINE__);
list ($ID_MSG, $context['topic_subject'], $message, $context['topic_starter']) = mysql_fetch_row($request);


And that line in Post.english.php would read:

$txt[130] = "Regards,\n " . (!empty($context['topic_starter']) ? $context['topic_starter'] : 'The ' . $context['forum_name'] . ' Team.') . "";

And this should work I would imagine, but if you have problems, please let us know. :)
Dev Consultant
Former SMF Doc Coordinator

sumocomputers

OK, that seems to work.  Thank you very much.

Just a question.  The part:

The ' . $context['forum_name'] . ' Team.') . "";

Doesn't seem to actually do anything (forum_name and Team do not appear in the bottom of the email).  Is this piece needed?

codenaught

Quote from: sumocomputers on July 15, 2007, 03:57:43 PM
Doesn't seem to actually do anything (forum_name and Team do not appear in the bottom of the email).  Is this piece needed?
As I mentioned earlier in this topic, I would recommend adding the check in case the username is not set. That variable is specifically set for sending announcements, so other emails that aren't announcements that do not have that variable set will instead print the "Forum Name Team".
Dev Consultant
Former SMF Doc Coordinator

sumocomputers

Quote from: akabugeyes on July 15, 2007, 04:01:51 PM
Quote from: sumocomputers on July 15, 2007, 03:57:43 PM
Doesn't seem to actually do anything (forum_name and Team do not appear in the bottom of the email).  Is this piece needed?
As I mentioned earlier in this topic, I would recommend adding the check in case the username is not set. That variable is specifically set for sending announcements, so other emails that aren't announcements that do not have that variable set will instead print the "Forum Name Team".

OK, I get it now.  Sorry, I didn't put the 2 together  :-[

Thanks again!

Advertisement: