Hoheria Posted July 2, 2006 Posted July 2, 2006 I've spent ages looking through this great help site and I cannot find a contribution that does anything as simple as this - yes you can have popup images but not easily clickable links to text explanations. I'd like to be able to have a few simple links to popup windows which give the customer supplimentary information on various ordering issues- in this case some info on which regions cannot be delivered by this particular delivery method. On the page with the relevant bit of text I'd like to put a link to the (javascipt) popup. My index.php file has in the header <script type="text/javascript" language="javascript"> <!-- function OpenPopup © { window.open(c, 'window', 'width=250,height=200,scrollbars=no,status=yes,screenX=150,screenY=150,top=15 0,left=150'); } //--> </script> And in: catalog\includes\languages\english\modules\shipping\regions.php I'm trying to get this link to work: define('MODULE_SHIPPING_UKREGIONS_TEXT_TITLE', 'Plants sent in pots by UK next day carrier . . . <a href="carrier.htm" onclick="OpenPopup(this.href); return false">more</a>'); With carrier.htm being a simple page of explanitary text. Now my almost no existent understanding of php tells me I should encase the bit of javascript with something like #echo " ................ code here ................... \n"; so that the script is read properly but I am unable to get the thing to work without error messages of the "unexpected character on line 16" nature. Help appreciated Martin
choosealogin Posted July 3, 2006 Posted July 3, 2006 That looks like it should work. What is the exact error you're getting, and on what page. One thing is, you'll need the JS function defined on the page that you're calling the OpenPopup function. I put your code in a test page, i.e. <?php define('MODULE_SHIPPING_UKREGIONS_TEXT_TITLE', 'Plants sent in pots by UK next day carrier . . . <a href="carrier.htm" onclick="OpenPopup(this.href); return false">more</a>'); echo MODULE_SHIPPING_UKREGIONS_TEXT_TITLE; ?> and it came up fine, with no errors. Maybe I missed something. Ok, it occured to me that maybe your function definition is creating the error. Keep it outside of the PHP tags.. i.e. php ended here ?> <----closed ---put your function OpenPopup here----- <? php starts here again
Hoheria Posted July 3, 2006 Author Posted July 3, 2006 Thanks Mark with your help and some more jiggering around I have it working nicely. I did have to put the javascript into the same file because it will not work from the index.php file. Also necessary to put in between header tags outside the php. Also change the script a little - php will not, it seems tolerate single quotes within the script - it seems to conflict with 'Plants sent in pots etc text which is written to the page. For the sake of tidiness I've closed the body and html tags -seems to work OK here any comments? I did try the function definition outside the php tags and it was then written to the page! Martin So: catalog\includes\languages\english\modules\shipping\regions.php now reads . . . <?php /* $Id: regions.php,v 1.2 2001/10/15 07:07:45 Jorge Exp $ The Exchange Project - Community Made Shopping! http://www.theexchangeproject.org Copyright © 2000,2001 The Exchange Project Released under the GNU General Public License */ ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <script type="text/javascript" language="javascript"> <!-- function openpopup(url, windowtarget) { window.open( url, windowtarget, 'width=350,height=250,toolbar=0,location=0,directories=0,status=0,menubar=0,s crollbars=0,resizable=0,top=50,left=50'); } // --> </script> </head><body></body></html><?php define('MODULE_SHIPPING_UKREGIONS_TEXT_TITLE', 'Plants sent in pots by UK next day carrier . . . <a href="carrier.htm" target="popup1" onclick="openpopup(this.href); return false;">more</a>'); define('MODULE_SHIPPING_UKREGIONS_TEXT_DESCRIPTION', 'Rates Based on Regions (group of Regions and/or Counties)'); define('MODULE_SHIPPING_UKREGIONS_ITEMS', 'Delivering'); define('MODULE_SHIPPING_UKREGIONS_ITEMS_TEXT', 'Items to'); define('MODULE_SHIPPING_UKREGIONS_WEIGHT', 'Delivering to'); define('MODULE_SHIPPING_UKREGIONS_WEIGHT_TEXT', 'Pounds to'); define('MODULE_SHIPPING_UKREGIONS_TEXT_WAY', 'Delivering to'); define('MODULE_SHIPPING_UKREGIONS_TEXT_UNITS', ' '); define('MODULE_SHIPPING_UKREGIONS_INVALID_ZONE', 'No delivery available to the selected location'); define('MODULE_SHIPPING_UKREGIONS_UNDEFINED_RATE', 'The delivery cost cannot be determined at the moment'); ?>
Hoheria Posted July 4, 2006 Author Posted July 4, 2006 Ha! well I thought that was right but I've now looked farther and learnt a little bit in the process. In fact there was still an error message on trying to proceed to the next page during shipping which told me that the correct place to put the javascipt is in checkout_shipping.php so at line 195 I've inserted // windows popup used on shipping page function openpopup(url, windowtarget) { window.open( url, windowtarget, 'width=400,height=250,toolbar=0,location=0,directories=0,status=0,menubar=0,s crollbars=0,resizable=0,top=50,left=50'); } this is at the end of a big section with various bits of script. There is no script and no headers etc on the various shipping options pages and this (eg) in the catalog\includes\languages\english\modules\shipping\flat.php file on line 14 define('MODULE_SHIPPING_FLAT_TEXT_TITLE', 'Posted as root washed plants in early spring . . . <a href="flat.htm" target="popup1" onclick="openpopup(this.href); return false;">more</a>'); If I do any more text popups elsewhere I'll post it here in case it helps someone. Martin
Recommended Posts
Archived
This topic is now archived and is closed to further replies.