Tokyoj

Topic: Adding a $msg component to 'Send to a Friend' email

I'm trying to add the job title and company name of the position being send via the 'Send to a Friend' function in class.Postman.php so I created

$msg .= "\n\nTitle: " . $data['title'] . "\n\nCompany: " . $data['company'];

and added it to

class.Postman.php

and also added

$data

to

public function MailSendToFriend($friend_email, $my_email, $my_message, $data)

thinking it was required. In the end I get the below...(I purposely left out the if { else } portion of the code for posting here)...but the email still leaves out the
$data['title']  and $data['company'] strings.

// Send a job post to a friend
public function MailSendToFriend($friend_email, $my_email, $my_message, $data)
    {
        $subject = SITE_NAME;
        $subject .= "Job Recommendation !!!";
        $msg .= "\n\nThis email " . $my_email . 'recommends a job to you.';
        $msg .= "\n\nYour friend's message is:" . $my_message;
        $msg .= "\n\nTitle: " . $data['title'] . "\n\nCompany: " . $data['company'];
        $msg .= "\nTo view the job, click here:" . $_SERVER['HTTP_REFERER'];

What do I need to do to get those two stings included in the email?
Thank you.

---------------
Tokyoj
"You can't build a reputation on what you're going to do." (Henry Ford)
"Insanity is doing the same thing over and over, expecting different results." (Albert Einstein)

Chronos

Re: Adding a $msg component to 'Send to a Friend' email

The 'recommend to friend' is a form that only posts it's own fields to the public function. By default it does not send any other values like title, company etc. To include these, follow the following steps:

1. Open job.tpl and find the 'send-to-friend' form

2. Add the wanted data as hidden fields:

- Use for name and id the respective data (like company)
- Use for the values the same SMARTY code like "$job.company"
- Add the hidden variables just before the submit button
- For more information about hidden fields see http://www.echoecho.com/htmlforms07.htm

3. Now that these values are also posted, you should adjust page_sendtofriend.php to include them

- Add the variables at the spot where the function is run, using the same name as you've given the field (and in the same order)

4. Lastly open the the class.Postman.php and adjust the function parameters the same way as the other file, and add the data somewhere in the message

Last edited by Chronos (2009-02-18 11:45:42)

Member of Jobberbase Development Team - Implementation and Coding

Visit my Blog: ChronoScripts (JobberBase scripts, support and freelance)
JobBoards: Telefonisch Werk and Top Bijbaan

Tokyoj

Re: Adding a $msg component to 'Send to a Friend' email

Everything seems/seemed to work well, until the email.

The email outputs only the hard text 'Company' and 'Title' but not their strings. (See below)
Company:
Title:

Here's what I did...

From page_sendtofriend.php...
    if ($costel->MailSendToFriend($friend_email, $my_email, $my_message, $employer_name, $job_title))
    {
    echo '1';
    }

From job.tpl...
<td colspan="2">
  <input type="hidden" name="employer_name" value="employer_name" />
  <input type="hidden" name="job_title" value="job_title" />
  <input type="submit" name="submit" id="submit" value="{$translations.recommend.submit}" />
  <span id="send-to-friend-response"></span>
</td>                         

From class.Postman.php...
     public function MailSendToFriend($friend_email, $my_email, $my_message, $employer_name, $job_title)
    {
     $subject = SITE_NAME;
     $subject .= "Job Recommendation !!!";
     $msg .= "\n\nThis email " . $my_email . 'recommends a job to you.';
     $msg .= "\n\nYour friend's message is:" . $my_message;
     $msg .= "\n\nCompany: " . $data['employer_name'] . " \nTitle:" . $data['job_title'];   
     $msg .= "\nTo view the job, click here:" . $_SERVER['HTTP_REFERER'];
etc...etc...

I'm thinking the problem could be 1,2, or 3 things:
1) I've mislabeled the $data['company'] strings, so tried
$msg .= "\n\nCompany: " . $employer_name . " \nTitle:" . $job_title;   
but that of course only outputs the text company_name and job_title
and/or

2) I use
$employer_name and $job_title
where it should be
$employer.name and $job.title

or

3) I'm doing everything correctly and the rest of the world is crazy... ha ha.

Would anyone be able to help out?
Thanks

---------------
Tokyoj
"You can't build a reputation on what you're going to do." (Henry Ford)
"Insanity is doing the same thing over and over, expecting different results." (Albert Einstein)

putypuruty

Re: Adding a $msg component to 'Send to a Friend' email

Hi.

I'll try to help you in the evening (GMT + 2), if you don't succeed until then.

Chronos

Re: Adding a $msg component to 'Send to a Friend' email

Most of the code seems alright, there's a few mistakes though:

- The class.Postman.php would use '$employer_name' and '$jobtitle' instead of '$data['employer_name']', just like the other fields.

- The hidden fields in the form should contain dynamic SMARTY code. For debugging purposes it's a good idea to start like they are now (which is; pure text), so you know the values are read and used by the other adjustments. However for the script to work properly they should be in the form of:

Code:
<input type="hidden" name="job_title" value="{$job.company}" />
Member of Jobberbase Development Team - Implementation and Coding

Visit my Blog: ChronoScripts (JobberBase scripts, support and freelance)
JobBoards: Telefonisch Werk and Top Bijbaan

Tokyoj

Re: Adding a $msg component to 'Send to a Friend' email

"Give a person a fish, feed 'em for a day. Teach a person to fish, feed 'em for life"
That did it. Thank you.

I'll try to put together a tutorial for less skilled coders like me and post it later.

---------------
Tokyoj
"You can't build a reputation on what you're going to do." (Henry Ford)
"Insanity is doing the same thing over and over, expecting different results." (Albert Einstein)

evertsemeijn

Re: Adding a $msg component to 'Send to a Friend' email

Tokyoj wrote:

"Give a person a fish, feed 'em for a day. Teach a person to fish, feed 'em for life"

big_smile

Member of Jobberbase Development Team - Templates/Usability :: Looking for installation and/or custom design? :: Beautiful Wordpress themes