Forums / Templates, Stylesheets, Page Layout / using a variable in the product description for a popup

using a variable in the product description for a popup

Locked

Views: 1,717

Results 1 to 10 of 10
This thread is locked. New replies are disabled.
16 Apr 2010, 4:00 PM
#1
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,876
Plugin Contributions:
7

using a variable in the product description for a popup

In the product description text I want to use a link which will open a popup window using javascript.

The content of this window is a flash swf hosted offsite (it contains up-to-the-minute product information). There are two swf files that I want to be be retrieved, depending on the language selected at the time as I have a dual language shop.

As far as I understand I cannot link directly to the swf file, I need to embed it in some html to ensure it is handled properly by browsers without flash.

I have the popup working ok linking directly to a html file in my shop root.

<a href="javascript:popupWindow(\'define_ht_product_advisor_es.html\')">Product Advisor</a>

But I know it should not live there but in here

\includes\languages\english\html_includes\my_template folder

So, I make a new file

\includes\extra_datafiles\define_custom_filenames.php
with this in it

<?php
define(‘FILENAME_DEFINE_HT_PRODUCT_ADVISOR’, ‘define_ht_product_advisor’);
?>

and in

\includes\modules\pages\product_info\header_php.php
I put

$define_page = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_HT_PRODUCT_ADVISOR, 'false');

and if I test this using the $define_page variable in the template somewhere it gets loaded with the correct path ok.

The problem is how to use this in the javascript in the product description.

Using this in the description:

<a href="javascript:popupWindow(\'<?php echo $define_page ?>\')">Product Advisor</a>
gets stored and used literally so the html output to the browser is

<a href="javascript:popupWindow('<?php echo $define_page ?>')">Product Advisor</a>

So how should I be approaching this?

thanks
Steve

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

16 Apr 2010, 4:59 PM
#3
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,876
Plugin Contributions:
7

Re: using a variable in the product description for a popup

I did look at that post thanks.

It uses static links in the js file. I would either need to have two functions which call the two different files I require or pass a language variable or path to the function, either of which would be a solution.

The other issue is ensuring the links work when javascript is turned off.
So as far as I know I would need something like this in each product description:
English

<a href="ht_product_advisor_en.html" target="_blank" onclick="openWindow(ht_product_advisor_en.html); return false;">Product Advisor</a>

spanish

<a href="ht_product_advisor_es.html" target="_blank" onclick="openWindow(ht_product_advisor_es.html); return false;">Product Advisor</a>

I guess I was wondering if there was a more elegant solution than this.

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

17 Apr 2010, 5:43 PM
#4
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,876
Plugin Contributions:
7

Re: using a variable in the product description for a popup

This is what I ended up with, for reference.

The link opens a small popup window to the left of the product description, over the menu, with the flash file embedded.

If javascript is disabled, it opens a new window.

While it would seem more efficient to pass a language variable to a single javascript function, I found that passing ANY variable would result in the function ALWAYS opening a new window and never a popup.
Maybe someone knows how to fix that.

Code used in the Product Descriptions
English

<a href="includes/languages/english/html_includes/MY_TEMPLATE/ht_product_advisor_en.html" target="_blank" onclick="ht_pa_en(); return false;">Product Advisor</a>
Spanish
<a href="includes/languages/spanish/html_includes/MY_TEMPLATE/ht_product_advisor_es.html" target="_blank" onclick="ht_pa_es(); return false;">Product Advisor</a>

Javascript

<script language="javascript" type="text/javascript">
<!--
// open Product Advisor EN
function ht_pa_en() {window.open('includes/languages/english/html_includes/MY_TEMPLATE/ht_product_advisor_en.html','popupWindow','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=210,height=290,screenX=150,screenY=200,top=200,left=150')
}
// open Product Advisor ES
function ht_pa_es() {window.open('includes/languages/spanish/html_includes/ MY_TEMPLATE /ht_product_advisor_es.html','_blank','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=210,height=290,screenX=150,screenY=200,top=200,left=150')
}
//--></script>

And the English target file "ht_product_advisor_en.html" with the flash, which DOES validate. Spanish file is similar with the obvious differences.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head><title>Product Advisor</title>
</head>
<body>
<object data="http://www.otherdomain.com/dealers_area/ht_product_advisor_en.swf" type="application/x-shockwave-flash" width="200" height="275">
<param name="movie" value="http://www. otherdomain.com/dealers_area/ht_product_advisor_en.swf" />               
</object>
</body>
</html>

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

17 Apr 2010, 5:46 PM
#5
haredo avatar

haredo

Totally Zenned

Join Date:
Apr 2006
Location:
Texas
Posts:
6,187
Plugin Contributions:
0

Re: using a variable in the product description for a popup

To,
Thanks for the contribution, benefits the Zen community...
Do you have a site to view this working variable???

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.

Zen Cart Certified hosting at myZenCartHost.com.

17 Apr 2010, 6:01 PM
#6
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,876
Plugin Contributions:
7

Re: using a variable in the product description for a popup

Hi,
I started the thread to see if there was a way to use a variable in the product description and it appears there is not.

What I have posted is just what I ended up doing instead: there are no variables in sight, everything is hard-coded in my example.
I just posted it in case it saves someone some time. I am very time poor and totally reliant on finding what I need quickly in this forum, so I try and give back as I go along/discover things,

regards
Steve

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

17 Apr 2010, 6:04 PM
#7
haredo avatar

haredo

Totally Zenned

Join Date:
Apr 2006
Location:
Texas
Posts:
6,187
Plugin Contributions:
0

Re: using a variable in the product description for a popup

To,
Do you have a link to view this popup???

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.

Zen Cart Certified hosting at myZenCartHost.com.

17 Apr 2010, 6:11 PM
#8
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,876
Plugin Contributions:
7

Re: using a variable in the product description for a popup

No, I do all my dev. work on a local laptop as I work abroad a lot. I have ftp blocked from where I am now so I can't update my online development site - not for another month!
I can send you this if you want, pm me,

regards
Steve

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

17 Apr 2010, 6:16 PM
#9
haredo avatar

haredo

Totally Zenned

Join Date:
Apr 2006
Location:
Texas
Posts:
6,187
Plugin Contributions:
0

Re: using a variable in the product description for a popup

To,
PM sent....

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.

Zen Cart Certified hosting at myZenCartHost.com.

17 Apr 2010, 6:24 PM
#10
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,876
Plugin Contributions:
7

Re: using a variable in the product description for a popup

Actually, I have to crash out now, (up at 5am) so in the interests of speed, you should copy the code I pasted.

The javascript goes in the includes/modules/pages/product_info folder.
The only other things you have to change are the MY_TEMPLATE references for yours and put valid address for the swf file in the product description and the javascript.
Everything else is there. Any problems let me know, but no replies for 10 hours,

regards
Steve

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...