X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   send_to_friend.tpl pop up (https://forum.x-cart.com/showthread.php?t=32932)

luxor 07-31-2007 02:36 PM

send_to_friend.tpl pop up
 
I am having trouble creating a seperate page for just a send to friend popup form.

I would like to have a send to friend button on the product page, which will then load a popup window with the send a friend form.


Now I can probably most easily create a rogue php page which takes the current url as a post variable and have a seperate mail form and function to make this happen.


However I would like to try to keep the form in x-cart form, so that it will use the internal css, popup code, and internal language variables and mail functions.

Can anyone point me in the right direction?

geckoday 07-31-2007 04:48 PM

Re: send_to_friend.tpl pop up
 
I'd go about it this way:

skin1/customer/main/product.tpl
Modify to pop up window url product.php?productid=xxx&mode=showsend when button is clicked for send to friend
remove include of send_to_friend.tpl

send_to_friend.php
Modify to set $main="showstf" and assign to smarty variable if mode=showsend. See first few lines of product.php for how its done.

skin1/customer/home_main.tpl
modify to use customer/main/send_to_friend.tpl when main=showstf

skin1/customer/main/send_to_friend.tpl
modify as desired for your popup window

This way all variables that are available on your product page are available on your send to friend popup page and you use the normal X-Cart sned to friend logic to send the email.

luxor 07-31-2007 10:42 PM

Re: send_to_friend.tpl pop up
 
i tried to follow your idea.

just to make sure i am doing what you are thinking

i added this to send_to_friend.php :

Code:

$main = "showstf";

if($mode==showsend){
$smarty->assign("showstf",$main);
}



other then that i followed your ideas. i could not get it to work, with this instruction the link is now loading the product page over when i click send to friend button / link.

I think this is the right track, but missing something...

geckoday 08-01-2007 06:03 AM

Re: send_to_friend.tpl pop up
 
Try this in send_to_friend.php:

Code:

if($mode=='showsend'){
  $main="showstf";
  $smarty->assign("main",$main);
}


luxor 08-01-2007 10:50 PM

Re: send_to_friend.tpl pop up
 
8O

That code worked. Cheers to you for that!


Now I just have to work on removing the template around the loaded page.

I am having a bit of trouble of where the connection in these files and modifications to calling the overall template to load, and be able to modify that for this particular page load.


[UPDATE]

I have figured a way to do it.

You can have an if statement in home.tpl to load if $main ne showstf

else load home_main.tpl, which will then load only the tell a friend tpl.

is this the best solution in your opinion?
Also with this method it takes a way the ability to dynamically control the title of the window and meta info etc. (copies product page data). Any idea on how to setup this page with logical control of these items from xcart for my new window. I have not yet worked with the static page creation of x-cart, is it possible to create a static page in xcart admin with meta and title control, and then somehow load the mod into this static page?

One other problem I am having is that when i close out the pop up window, the main window on the next page click will show the notification box that states my recommendation has been sent, which of course is not good. Do you have an idea on how to correct this issue?


Thanks and regards.

geckoday 08-02-2007 06:59 AM

Re: send_to_friend.tpl pop up
 
Right. I wasn't thinking about all the site banner and navigation stuff. What you did should work fine. Probably the best way to go is at the bottom of product.php replace:
Code:

func_display("customer/home.tpl",$smarty);
with:
Code:

if ($main == 'showstf')
  func_display("customer/main/send_to_friend",$smarty);
else
  func_display("customer/home.tpl",$smarty);


geckoday 08-02-2007 07:01 AM

Re: send_to_friend.tpl pop up
 
Quote:

Originally Posted by luxor
One other problem I am having is that when i close out the pop up window, the main window on the next page click will show the notification box that states my recommendation has been sent, which of course is not good. Do you have an idea on how to correct this issue?


That message is setup in send_to_friend.tpl. Just take out the line:
Code:

$top_message["content"] = func_get_langvar_by_name("txt_recommendation_sent");

luxor 08-02-2007 08:24 PM

Re: send_to_friend.tpl pop up
 
Quote:

Originally Posted by geckoday
Right. I wasn't thinking about all the site banner and navigation stuff. What you did should work fine. Probably the best way to go is at the bottom of product.php replace:
Code:

func_display("customer/home.tpl",$smarty);
with:
Code:

if ($main == 'showstf')
  func_display("customer/main/send_to_friend",$smarty);
else
  func_display("customer/home.tpl",$smarty);



Code:

if ($main == 'showstf')
  func_display("customer/main/send_to_friend.tpl",$smarty);
else
  func_display("customer/home.tpl",$smarty);


did not work. it loads the page without css and the send button does not work.

geckoday 08-02-2007 09:07 PM

Re: send_to_friend.tpl pop up
 
Quote:

Originally Posted by luxor
Code:

if ($main == 'showstf')
  func_display("customer/main/send_to_friend.tpl",$smarty);
else
  func_display("customer/home.tpl",$smarty);


did not work. it loads the page without css and the send button does not work.

You'll need to modify send_to_friend.tpl to be a stripped down X-Cart page. skin1/customer/preview.tpl is one you can look at for how to do this - it has the stuff to include the css. You could just gut everything in it between <body> and </body> and plug in the send to a friend stuff. I don't see any reason why the send button wouldn't work though. What does not working mean? Nothing happens at all when you click the button? Or ???

abeight 07-17-2008 12:19 PM

Re: send_to_friend.tpl pop up
 
I got this working, but after you click the send button, the product page shows in the pop-up window. Can that be changed to just say "thank you" or something along those lines?

Once I get this working 100% I'll post all of the code in one entry.

Thanks!

luxor 07-17-2008 12:37 PM

Re: send_to_friend.tpl pop up
 
I have a simple solution I use.

add this to the end of send_to_friend.php before the final }

func_header_location("thankyoupage.php");

this will load thankyoupage.php after a succesful submit. you can stylize this page all you like.

abeight 07-17-2008 01:04 PM

Re: send_to_friend.tpl pop up
 
Thank you, Luxor!

abeight 07-17-2008 01:29 PM

Re: send_to_friend.tpl pop up
 
Here are the steps that I followed to get this working in 4.1.9 based on other posts in this thread. I just thought someone else might find it helpful to have everything in one place. Let me know if I missed anything. ;)

1. Place pop-up link somewhere in skin1/customer/main/product.tpl

Code:

<A HREF="javascript:popUp('product.php?productid={$product.productid}&mode=showsend')">Email A Friend</A>

2. Place this pop-up script in <head> section of skin1/customer/home.tpl (just a free script I found online - credits are in place):

Code:

{literal}
<SCRIPT LANGUAGE="JavaScript">
<!-- Idea by:  Nic Wolfe -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=450,height=200,left = 287,top = 284');");
}
// End -->
</script>
{/literal}


3. In send_to_friend.php:

Add:

Code:

if($mode=='showsend'){
  $main="showstf";
  $smarty->assign("main",$main);
}


Replace (only if you want a custom thank you page):

Code:

func_header_location("product.php?productid=".$productid);

with:
func_header_location("thankyou.php");


4. In product.php:

Replace:
Code:

func_display("customer/home.tpl",$smarty);

with:
Code:

if ($main == 'showstf')
  func_display("customer/main/send_to_friend.tpl",$smarty);
else
  func_display("customer/home.tpl",$smarty);



5. Alter your skin1/customer/main/send_to_friend.tpl file to have the look and feel that you want. Mine looks like this:

Code:

{* $Id: send_to_friend.tpl,v 1.11.2.5 2007/04/05 10:17:48 twice Exp $ *}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
{config_load file="$skin_config"}
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Email A Friend</title>
{include file="meta.tpl" }
<link rel="stylesheet" href="{$SkinDir}/{#CSSFile#}" />
</head>
<body{$reading_direction_tag}{if $body_onload ne ''} onload="javascript: {$body_onload}"{/if}>
<div style="width: 450px; height: 200px; background-color: #FFF;">
<script type="text/javascript" language="JavaScript 1.2">
<!--
var requiredFields = new Array();
requiredFields[0] = new Array('send_name', "{$lng.lbl_send_your_name|strip_tags|replace:'"':'\"'}", false);
requiredFields[1] = new Array('send_from', "{$lng.lbl_send_your_email|strip_tags|replace:'"':'\"'}", false);
requiredFields[2] = new Array('send_to', "{$lng.lbl_recipient_email|strip_tags|replace:'"':'\"'}", false);
-->
</script>
{include file="check_required_fields_js.tpl"}
{include file="check_email_script.tpl"}
{capture name=dialog}
<form action="product.php" method="post" name="send">
<input type="hidden" name="mode" value="send" />
<input type="hidden" name="productid" value="{$product.productid}" />
<table>
<tr>
    <td class="FormButton">{$lng.lbl_send_your_name}:</td>
        <td><font class="Star">*</font></td>
    <td><input id="send_name" type="text" size="45" name="name" value="{$send_to_friend_info.name|escape}"/>{if $send_to_friend_info.fill_err and $send_to_friend_info.name eq ''}<front class="Star">&lt;&lt;</font>{/if}</td>
</tr>
<tr>
        <td class="FormButton">{$lng.lbl_send_your_email}:</td>
        <td><font class="Star">*</font></td>
        <td><input id="send_from" type="text" size="45" name="from" value="{$send_to_friend_info.from|escape}" onchange="javascript: checkEmailAddress(this);" />{if ($send_to_friend_info.fill_err and $send_to_friend_info.from eq '') or $send_to_friend_info.from_failed eq "Y"}<front class="Star">&lt;&lt;</font>{/if}</td>
</tr>
<tr>
    <td class="FormButton">{$lng.lbl_recipient_email}:</td>
        <td><font class="Star">*</font></td>
    <td><input id="send_to" type="text" size="45" name="email" onchange="javascript: checkEmailAddress(this);" value="{$send_to_friend_info.email|escape}"/>{if ($send_to_friend_info.fill_err and $send_to_friend_info.email eq '') or $send_to_friend_info.email_failed eq "Y"}<front class="Star">&lt;&lt;</font>{/if}</td>

</tr>
{if $active_modules.Image_Verification and $show_antibot.on_send_to_friend eq 'Y'}
{include file="modules/Image_Verification/spambot_arrest.tpl" mode="simple" id=$antibot_sections.on_send_to_friend antibot_err=$antibot_friend_err}
{/if}
<tr>
        <td colspan="3"><br />{include file="buttons/button.tpl" style="button" button_title=$lng.lbl_send_to_friend href="javascript: if(checkRequired(requiredFields)) document.send.submit();"}</td>
</tr>
</table>
</form>
{/capture}
{include file="dialog.tpl" title=$lng.lbl_send_to_friend content=$smarty.capture.dialog extra='width="100%"'}
</div>
</body>
</html>


6. If you want a custom thank you page, create a new file called thankyou.php and upload it to the root x-cart directory.

abeight 07-17-2008 02:18 PM

Re: send_to_friend.tpl pop up
 
Here's a quick question if anyone knows - I'm now attempting to turn the pop up link into a button, but it isn't working because I have brackets within brackets:

Code:

{include file="buttons/email_a_friend.tpl" style="button" href="javascript:popUp('product.php?productid={$product.productid}&mode=showsend')"}

Is there a way around this? :)

PhilJ 07-17-2008 02:24 PM

Re: send_to_friend.tpl pop up
 
maybe try...
Code:

{include file="buttons/email_a_friend.tpl" style="button" href="javascript:popUp('product.php?productid=`$product.productid`&mode=showsend')"}

abeight 07-17-2008 02:30 PM

Re: send_to_friend.tpl pop up
 
Thank you, Phil! That works!! :) Woo hoo!

soleag 07-28-2008 09:51 PM

Re: send_to_friend.tpl pop up
 
I'm having trouble with this code in 4.1.10. My popup window just displays the product page, no "Send To Friend " template. Should it work in 4.1.10?

gb2world 08-07-2008 10:24 PM

Re: send_to_friend.tpl pop up
 
Thanks for the mod.

There are a couple of changes I had to make to Andrea's summary in post #13 to get it to work for me.

1 - The code for product.php needs to add the ".tpl" after:
func_display("customer/main/send_to_friend.tpl",$smarty);

(Soleag - this could explain it not working for you if you used this code)

2. In the modified code for skin1/customer/main/send_to_friend.tpl, the send button did not work for me, I believe, because some javascript is missing. I added this before the </head>:
Code:

<script src="/skin1/common.js" language="JavaScript" type="text/javascript"></script>

This could be because I am using a shadowbox and not the popup javascript. Maybe the popup still finds the common.js with a popup. I'm not sure.

TanyaG 01-06-2009 05:34 AM

Re: send_to_friend.tpl pop up
 
Hi, not sure what I’m doing wrong but for some reason my popup window displays template of product page instead of sent_to_friend. Could anybody help me with it. Many thanks

Vetrivel 01-06-2009 05:39 AM

Re: send_to_friend.tpl pop up
 
Check the 4th step in post 13 of this thread.
Quote:

Originally Posted by TanyaG
Hi, not sure what I▓m doing wrong but for some reason my popup window displays template of product page instead of sent_to_friend. Could anybody help me with it. Many thanks


TanyaG 01-06-2009 07:46 AM

Re: send_to_friend.tpl pop up
 
Quote:

Originally Posted by Vetrivel
Check the 4th step in post 13 of this thread.

Thanks, Vetrivel! That works!

flyclothing 01-20-2009 10:00 PM

Re: send_to_friend.tpl pop up
 
Hi,

I did all of the above and double checked the listed changes, but still can't get this to work. I added graphics with a pop-up window, but the pop-up window is blank. Any thoughts to what I missed or need to add?

Is this the correct link to use?

<a target="_blank" HREF="javascript:popUp('product.php?productid={$pr oduct.productid}&mode=showsend')">

Example:

http://www.flyclothing.com/Bob-Marley-Bolt-T-Shirt-pr-21662.html

Learner 05-06-2009 04:00 AM

Re: send_to_friend.tpl pop up
 
Quote:

Originally Posted by abeight
Here are the steps that I followed to get this working in 4.1.9 based on other posts in this thread. I just thought someone else might find it helpful to have everything in one place. Let me know if I missed anything. ;)

1. Place pop-up link somewhere in skin1/customer/main/product.tpl

Code:

<A HREF="javascript:popUp('product.php?productid={$product.productid}&mode=showsend')">Email A Friend</A>

2. Place this pop-up script in <head> section of skin1/customer/home.tpl (just a free script I found online - credits are in place):

Code:

{literal}
<SCRIPT LANGUAGE="JavaScript">
<!-- Idea by:  Nic Wolfe -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=450,height=200,left = 287,top = 284');");
}
// End -->
</script>
{/literal}


3. In send_to_friend.php:

Add:

Code:

if($mode=='showsend'){
  $main="showstf";
  $smarty->assign("main",$main);
}


Replace (only if you want a custom thank you page):

Code:

func_header_location("product.php?productid=".$productid);

with:
func_header_location("thankyou.php");


4. In product.php:

Replace:
Code:

func_display("customer/home.tpl",$smarty);

with:
Code:

if ($main == 'showstf')
  func_display("customer/main/send_to_friend.tpl",$smarty);
else
  func_display("customer/home.tpl",$smarty);



5. Alter your skin1/customer/main/send_to_friend.tpl file to have the look and feel that you want. Mine looks like this:

Code:

{* $Id: send_to_friend.tpl,v 1.11.2.5 2007/04/05 10:17:48 twice Exp $ *}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
{config_load file="$skin_config"}
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Email A Friend</title>
{include file="meta.tpl" }
<link rel="stylesheet" href="{$SkinDir}/{#CSSFile#}" />
</head>
<body{$reading_direction_tag}{if $body_onload ne ''} onload="javascript: {$body_onload}"{/if}>
<div style="width: 450px; height: 200px; background-color: #FFF;">
<script type="text/javascript" language="JavaScript 1.2">
<!--
var requiredFields = new Array();
requiredFields[0] = new Array('send_name', "{$lng.lbl_send_your_name|strip_tags|replace:'"':'\"'}", false);
requiredFields[1] = new Array('send_from', "{$lng.lbl_send_your_email|strip_tags|replace:'"':'\"'}", false);
requiredFields[2] = new Array('send_to', "{$lng.lbl_recipient_email|strip_tags|replace:'"':'\"'}", false);
-->
</script>
{include file="check_required_fields_js.tpl"}
{include file="check_email_script.tpl"}
{capture name=dialog}
<form action="product.php" method="post" name="send">
<input type="hidden" name="mode" value="send" />
<input type="hidden" name="productid" value="{$product.productid}" />
<table>
<tr>
    <td class="FormButton">{$lng.lbl_send_your_name}:</td>
    <td><font class="Star">*</font></td>
    <td><input id="send_name" type="text" size="45" name="name" value="{$send_to_friend_info.name|escape}"/>{if $send_to_friend_info.fill_err and $send_to_friend_info.name eq ''}<front class="Star">&lt;&lt;</font>{/if}</td>
</tr>
<tr>
    <td class="FormButton">{$lng.lbl_send_your_email}:</td>
    <td><font class="Star">*</font></td>
    <td><input id="send_from" type="text" size="45" name="from" value="{$send_to_friend_info.from|escape}" onchange="javascript: checkEmailAddress(this);" />{if ($send_to_friend_info.fill_err and $send_to_friend_info.from eq '') or $send_to_friend_info.from_failed eq "Y"}<front class="Star">&lt;&lt;</font>{/if}</td>
</tr>
<tr>
    <td class="FormButton">{$lng.lbl_recipient_email}:</td>
    <td><font class="Star">*</font></td>
    <td><input id="send_to" type="text" size="45" name="email" onchange="javascript: checkEmailAddress(this);" value="{$send_to_friend_info.email|escape}"/>{if ($send_to_friend_info.fill_err and $send_to_friend_info.email eq '') or $send_to_friend_info.email_failed eq "Y"}<front class="Star">&lt;&lt;</font>{/if}</td>

</tr>
{if $active_modules.Image_Verification and $show_antibot.on_send_to_friend eq 'Y'}
{include file="modules/Image_Verification/spambot_arrest.tpl" mode="simple" id=$antibot_sections.on_send_to_friend antibot_err=$antibot_friend_err}
{/if}
<tr>
    <td colspan="3"><br />{include file="buttons/button.tpl" style="button" button_title=$lng.lbl_send_to_friend href="javascript: if(checkRequired(requiredFields)) document.send.submit();"}</td>
</tr>
</table>
</form>
{/capture}
{include file="dialog.tpl" title=$lng.lbl_send_to_friend content=$smarty.capture.dialog extra='width="100%"'}
</div>
</body>
</html>


6. If you want a custom thank you page, create a new file called thankyou.php and upload it to the root x-cart directory.


Thanks abeight for your codes.But is it possible to send current browser address( Home page,category page,manufacture page url) directly to friend ?

Thanks to all.

gary02140 06-13-2009 01:29 PM

Re: send_to_friend.tpl pop up
 
Quote:

Originally Posted by abeight
Here's a quick question if anyone knows - I'm now attempting to turn the pop up link into a button, but it isn't working because I have brackets within brackets:

Code:

{include file="buttons/email_a_friend.tpl" style="button" href="javascript:popUp('product.php?productid={$product.productid}&mode=showsend')"}

Is there a way around this? :)


abeight,

Thanks a lot for the mod. Would you tell me which file and where I should insert this line into? I just see this thread and is trying to integrate it into my v4.1.12.

Gary

hoosierglass 06-13-2009 09:29 PM

Re: send_to_friend.tpl pop up
 
Another option would be to use Add This. This will not only let people email someone a page, but also will allow them to add the page as a favorite, google bookmark, twitter and several other options. It has it's own analytics and you can track how many times it is used, how it is used and on what pages it is used.

wites 03-11-2013 07:58 PM

Re: send_to_friend.tpl pop up
 
Hi, I tried to follow the codes but the popup page loads the whole product page over and not the send to friend form, I wonder if you can help me with this. Thanks!

-------------
X-cart v.4.5.4


All times are GMT -8. The time now is 12:23 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.