Hi all I have an editxml.php file that takes this code: <img src="RLW_001.jpg" title="Please click on photograph to purhase" caption="RLW_001.jpg" link="" /> Code (markup): and when run, turns it into this code: <img src="RLW_001.jpg" title="Please click on photograph to purchase" caption="RLW_001.jpg" link="javascript:NewWindow=window.open('/Payment_page2.php?name=RLW_001.jpg&album=Ecofair_2006 2006','myWindow','width=300,height=660,toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes');NewWindow.focus(); void(0);" /> Code (markup): I need to change the editxml.php so that it creates a xml file like this <img src="RLW_001.jpg" title="Please click on Photograph to purchase" caption="RLW_001.jpg" link="http://www.michaelshuttleworth.com/Payment_page2.php?name=RLW_001.jpg&album=Ecofair_2006" target="_self" /> Code (markup): Here is the editxml.php code that needs changing: <html> <head> <title>PHP Test</title> </head> <body> <?php $file = "images.xml"; $descriptor = fopen ($file, "r"); $contents = fread($descriptor , filesize($file)); $album = ''; $pos1 = strpos($contents, 'javascript:NewWindow'); if ($pos1 == false) { $pieces = explode('link=""', $contents); $op = ""; for ($i = 0; $i < count($pieces); $i++) { $tnpos = strpos($pieces[$i], 'tnPath="'); if ($tnpos !== false) { $titpos = strpos($pieces[$i], 'ssp_director/albums/', $tnpos); $titpos += 20; $titend = strpos($pieces[$i], '/', $titpos) - $titpos; $album = substr($pieces[$i], $titpos, $titend); //echo $album; } $halves = explode('<img src="', $pieces[$i]); $fileid = substr($halves[1], 0, 7); if (count($halves) > 1) { $halves[0] .= '<img src="'; $pos1 = strpos($halves[1], 'unavailable'); if ($pos1 == false) { $halves[1] .= "link=\"javascript:NewWindow=window.open('/Payment_page.php?name=" . $fileid . ".jpg&album=" . $album . "','myWindow','width=300,height=730,toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes');NewWindow.focus(); void(0);\""; } else { $halves[1] .= 'link=""'; } } $op .= $halves[0] . $halves[1]; } fclose($descriptor); unlink($file); //$descriptor = fopen ('images.txt', "w"); $descriptor = fopen ($file, "w"); fwrite($descriptor,$op); echo 'done! '; echo count($pieces); echo ' pieces processed'; fclose($descriptor); } else { echo 'This file has been processed already'; } ?> </body> </html> Code (markup): I guess the javascript newwindow code needs replacing, i have tried but can't quite get it right. If anyone out there can show me what to change i would be so so grateful. Many thanks Mike
If I'm reading your post correctly you just need to change this one line: $halves[1] .= "link=\"javascript:NewWindow=window.open('/Payment_page.php?name=" . $fileid . ".jpg&album=" . $album . "','myWindow','width=300,height=730,toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes');NewWindow.focus(); void(0);\""; to this: $halves[1] .= "link=\"javascript:NewWindow=window.open('http://www.michaelshuttleworth.com/Payment_page.php?name=" . $fileid . ".jpg&album=" . $album . "');NewWindow.focus(); void(0);\"";
It works fine, fantastic but...it is opening the page in a new window. Can you modify the code for me again so it opens in the same window. This is the code it produced after your mods <img src="RLW_002.jpg" title="If you would like to purchase a photograph then please click on your selected image, you will then be taken to the purchase page" caption="RLW_002.jpg" link="javascript:NewWindow=window.open('http://www.michaelshuttleworth.com/Payment_page2.php?name=RLW_002.jpg&album=robb_and_lucy');NewWindow.focus(); void(0);" /> Code (markup): Just to say this is the last step for me before i publish my site, i have never built a site before and it has been tough but enjoyable (i need some sleep) Cheers Mike
change line: $halves[1] .= "link=\"javascript:NewWindow=window.open('/Payment_page.php?name=" . $fileid . ".jpg&album=" . $album . "','myWindow','width=300,height=730,toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes');NewWindow.focus(); void(0);\""; PHP: to: $halves[1] .= "link=\"document.location.href='/Payment_page.php?name=" . $fileid . ".jpg&album=" . $album . "'\""; PHP:
Many thanks for the reply Can't get this code to work though... I know i am being stupid but where do i place my http://www.michaelshuttleworth.com I have tried many variations and the best i could get is... code working but still opening in new window....arggghhhhh Many thanks Mike
Try this: $halves[1] .= "link=\"javascript:document.location('http://www.michaelshuttleworth.com/Payment_page.php?name=" . $fileid . ".jpg&album=" . $album . "');\"";