Page 1 of 1

Send to Friend Module/Script

Posted: Thu May 10, 2007 9:58 am
by asim
Hi,

I had look in the Development area for a Send to Friend module but could not find one. Does anyone know of a module or script that sends the current page URL to a specified email address, perhaps with a small message, using CMSMS?

Thank you

Re: Send to Friend Module/Script

Posted: Thu May 10, 2007 10:03 am
by RonnyK

Re: Send to Friend Module/Script

Posted: Thu May 10, 2007 10:28 am
by asim
Thank You!

Re: Send to Friend Module/Script

Posted: Thu May 10, 2007 11:19 am
by asim
Hi,

It seems that this TAG needs to be included on every page for it to capture the URL, however I use an "Email" icon on top of each page which reads "Send to Friend" - how do I use the TAG so that it is not apparent on each page until the user clicks on the "Send to Friend" icon and then perhaps the form opens in a new window or even a new page but caputring the URL of the page they just came from - does that make sense?

Here is my site: www.jenniemarshtrust.org
Thanks

Re: Send to Friend Module/Script

Posted: Thu May 10, 2007 11:23 am
by RonnyK
I put it next to the print-icon in the template, so I don't need to repeat it on every page. I also tweaked it to give back the referring instead of the current page.

Check:

http://forum.cmsmadesimple.org/index.ph ... l#msg54035

Ronny

Re: Send to Friend Module/Script

Posted: Thu May 10, 2007 11:41 am
by asim
Hey RonnyK,

Much appreciated and very helpful post. However, I tried to change my PHP but it broke the entire TAG, I think I may have not changed the PHP correctly. Would it be possible to post your TAG/PHP here so that I can copy into mine? I understand the icon thing, thats exactly what I want to do, but I can not get the PHP working, any help would be great!

Thank you.

Re: Send to Friend Module/Script

Posted: Thu May 10, 2007 12:03 pm
by RonnyK
I'll post it later, as I'm on a location right now, where I don't have access to the FTP, so I can't check the scripts-folder.

Ronny

Re: Send to Friend Module/Script

Posted: Thu May 10, 2007 1:36 pm
by asim
Thanks matey. Just so I can make sure I was doing the correct thing. According to your original post,

http://forum.cmsmadesimple.org/index.php/topic,8698.msg54035.html#msg54035

Do I change all mention "REQUEST_URI" to

Code: Select all

$pageURL .= $_SERVER["HTTP_REFERER"];
OR is it just a specifc tag I change?

Thanks

Re: Send to Friend Module/Script

Posted: Thu May 10, 2007 1:39 pm
by RonnyK
I added the line after the original piece of code, to switch it to the reffering page, it should work if you put this single line just below the four/five lines concerning the original logic.

I left the original lines there, just added this line, to switch the "variable" from current to referring page.

Ronny

Re: Send to Friend Module/Script

Posted: Thu May 10, 2007 2:15 pm
by asim
Hi Ronny,

I still can not get it to work, below I have copied my code, I have also put in the comment "// RONNYK's SUGGESSTION:" this where I putted your code change, is this corrcect?


Code: Select all


	$errors=$to=$name=$email=$message = '';


 $pageURL = "\r\n\r\nhttp";
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 
// RONNYK's SUGGESSTION:
$pageURL .= $_SERVER["HTTP_REFERER"];

$message = $canned . $pageURL ;


	if($_SERVER['REQUEST_METHOD']=='POST'){
		if (!empty($_POST['subject'])) $subject = tafsanitize($_POST['subject']);
		if (!empty($_POST['to'])) $to = tafsanitize($_POST['to']);
		if (!empty($_POST['name'])) $name = tafsanitize($_POST['name']);
		if (!empty($_POST['email'])) $email = tafsanitize($_POST['email']);
		if (!empty($_POST['canned'])) $canned = $_POST['canned'];
		if (!empty($_POST['message'])) $message = $_POST['message'];
		
		if (FALSE == empty($params['captcha']) && $params['captcha'] && isset($gCms->modules['Captcha'])) 
		{
		    if (!empty($_POST['captcha_resp'])) { $captcha_resp = $_POST['captcha_resp']; }
		}






		//Mail headers


Re: Send to Friend Module/Script

Posted: Thu May 10, 2007 6:50 pm
by RonnyK
The snippet of my code:

Code: Select all

 #	$pageURL = "\r\n\r\nhttp";
 #	 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 #	 $pageURL .= "://";
 #	 if ($_SERVER["SERVER_PORT"] != "80") {
 #	  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 #	 } else {
 #	  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 #	 }

$pageURL .= $_SERVER["HTTP_REFERER"];

The part with "#" was the original, which I commented out, to be replaced with the referring page.

Ronny

Re: Send to Friend Module/Script

Posted: Fri May 11, 2007 1:03 pm
by asim
That worked, thank you Ronny.