Copy link to clipboard
Copied
Hi everyone,
I'm trying to use the Preload images behaviour in DW CS4, but since my site is dynamic using php I'm not sure how to get it working. I started out by doing the following:
I clicked on the body tag and then in the behaviours panel I chose Preload images. In the dialogue box that opened, I clicked the browse button next to image source file. Then in the next dialogue I chose the 'data sources' button so I could enter the path to the images: The following was what was in there to begin with:
<?php echo((isset($_SERVER[""]))?$_SERVER[""]:"") ?>
I deleted this and inserted the following:
<?php echo'<img src="../../../images/catalogue/business/corporate/<?php echo $item['itemImage'] . \'.jpg\''; ?>
When I clicked ok, this is what was in the body tag:
<body onload="P7_TMopen(); MM_preloadImages('<?php echo'<img src="../../../images/catalogue/business/corporate/<?php echo $item['itemImage'] . \'.jpg\''; ?>')">
As you can see there are two unrelated onload behaviours in the body tag now.
Copy link to clipboard
Copied
Your explanation is rather difficult to follow, but the reason you're getting the PHP error is obvious. You can't nest PHP tags inside each other.
<body onload="P7_TMopen(); MM_preloadImages('../../../images/catalogue/business/corporate/<?php echo $item['itemImage'];?>.jpg')">
Copy link to clipboard
Copied
Sorry I should have explained better. I just have a controller file with a whole lot of php that queries a database and then includes a template file where a slideshow is being output with the contents of the database. So I haven't used any of DW's server behaviours.
That said, I revised the code according to your suggestion and this eliminated the error, but just one thing. How can you tell if the behaviour is actually working. I mean I just tested and it doesn't seem as if the images are preloaded. You need to click on an image and then the larger version loads but this doesn't seem to be doing it very quickly so I kind of wondered if it was working.