PDA

View Full Version : Lightbox viewer w/ PHP-link call = No go.. please help



fivestar
06-18-2008, 12:41 AM
1) Script Title: Lighbox viewer (both versions)

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex4/lightbox/index.htm

3) Describe problem: Image won't load

The actual syntax for executing the script is:
<a href="dog.jpg" rel="lightbox" ><img src="dog_thumb.jpg" /></a>

What I'm trying to do:
<a href="<?php echo $this->getGalleryUrl($_image) ?>" rel="lightbox">

The only difference being that I'm putting in a PHP-link call in href instead of the actual image link, which btw I do not know as I'm working on a shopping cart and it keeps its own track of URLs.

I've done all the basics right, and I can even see the script run up to the point where it loads the image, but the image never shows up. Apparantly, lighbox doesn't like indirect image URLs. Any possible soluions? I'd imagine a few tweaks in the .js file will do me good, but i'm no hardcore coder so any bit of help is highly appreciated.

Oher info: that little piece of PHP code above is correct, and seems to work well with DHTML pop-up scripts.

jscheuer1
06-18-2008, 12:58 AM
If the PHP code is executing properly, lightbox has no way of knowing it's there, as it is exactly the same on the client side (where lightbox operates) as any hard coded URL.

I do know that in PHP, unlike in javascript, semicolons must terminate statements like echo, setting variables, etc. So your code should at least be:


<a href="<?php echo $this->getGalleryUrl($_image); ?>" rel="lightbox">

Additionally, I am not familiar with the:


$this->

syntax, it looks wrong to me, but that could just be my inexperience with PHP.

One way to test if your PHP token is getting resolved as expected is to look at the live page with the browser's 'view source'. It will show exactly how the code is being served. If it doesn't look right there, the PHP part is messing up somewhere. It could be the token itself, how it's written or the value it contains that's off though, or a combination.

It's also possible that your code could be correct (but I'm pretty sure about it's needing that semicolon), but that the image path and filename it produces points to a non-existent file.

fivestar
06-18-2008, 01:17 AM
If the PHP code is executing properly, lightbox has no way of knowing it's there, as it is exactly the same on the client side (where lightbox operates) as any hard coded URL.

I do know that in PHP, unlike in javascript, semicolons must terminate statements like echo, setting variables, etc. So your code should at least be:


<a href="<?php echo $this->getGalleryUrl($_image); ?>" rel="lightbox">

Additionally, I am not familiar with the:


$this->

syntax, it looks wrong to me, but that could just be my inexperience with PHP.

One way to test if your PHP token is getting resolved as expected is to look at the live page with the browser's 'view source'. It will show exactly how the code is being served. If it doesn't look right there, the PHP part is messing up somewhere. It could be the token itself, how it's written or the value it contains that's off though, or a combination.

It's also possible that your code could be correct (but I'm pretty sure about it's needing that semicolon), but that the image path and filename it produces points to a non-existent file.

The PHP part is perfectly legit, and I know this for sure because I can get the following to work,

<a href="#" onClick="getemail=dhtmlmodal.open('imgbox', 'iframe', '<?php echo $this->getGalleryUrl($_image) ?>','', 'width=600px,height=480px,center=1,resize=1,scrolling=0'); return false">

You can see the call function is the same for both, only the way it's manipulated differs. Unfortunately, the particular DHTML script offered on DD doesn't suit my likes, so I'm fairly desperate to get lightbox script to work for me. Do you think you can re-do some code in lightbox.js file?

jscheuer1
06-18-2008, 01:22 AM
Please post a link to the page on your site that contains the problematic code so we can check it out.