• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Preload images behaviour

Contributor ,
Mar 08, 2010 Mar 08, 2010

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.

When I tested the page, I got the following error:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/mysite/www/kc/business/catalogue/corporate/catalogue_business.php on line 68
Line 68 is the code in the body tag shown above.
I wondered if anyone knows what might be happening here and/or how to solve this?
Appreciate any assistance.

TOPICS
Server side applications

Views

826

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 08, 2010 Mar 08, 2010

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')">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 08, 2010 Mar 08, 2010

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines