I'm using a lightbox plugin to display a page with dynamic content in a lightbox, I need to pass a parameter id
from the < a > tag to the lightbox content.
This is the < a > tag
<a href="#?pid=<?php echo $image->pid;?>" class="lbp_singe-image">
And this is the lightbox content that will be displayed when I click on the link.
<div style="display:none">
<div id="lbp_singe-image">
<?php
$pid = $_GET["pid"]; //I need to get the ID
$pid = ereg_replace("[^0-9]", "", $pid);
$shortcode_output = do_shortcode('[singlepic id="' . $pid . '" w="" h=""]');
if ($shortcode_output=="[SinglePic not found]"){
echo ("No picture here");
}else {
echo do_shortcode('[singlepic id="' . $pid . '" w="" h=""]');
}
?>
</div>
</div>
The lightbox is working correctly, My problem is that I want to fetch the value from the link.
so what can I do here?
Update
It is a gallery page, contains many anchors, each anchor has $image->pid;
the shortcode supposed to run in separated page where the URL is full and php will be able to fetch the value with $_GET["pid"]
, but I need to run it in a lightbox instead and here where I can't use the url to get the ID.
The way you use the lightbox no request will be sent to the server, instead you display a content div that already is on the same page. That is why $_GET['pid']
is empty at that moment.
I see 2 possible solutions.
First, instead of $_GET['pid']
you use $image->pid
.
Second, if you want to send a request to the server when the link is clicked, use the technique described in the docs chapter "Secondary Lightbox General Usage":
http://www.23systems.net/wordpress-plugins/lightbox-plus-for-wordpress/demos/
A secondary lightbox can be used to display internal and external web pages, video or interactive flash. Secondary lightboxes must be set up manually and can use either a rel=”lightbox[id]” attribute or a class=”lbpModal” attribute to associate the link/content with the a lightbox.
So something like this should work:
<a class="lbpModal" href="[urlToScriptThatGeneratesYourContent]">click</a>
Note: I never used this plugin, nor have I tested this, it is just what I read from the docs.