...

View Full Version : add lightbox def to array value



durangod
10-26-2012, 02:42 AM
Hi, this is alittle of php, javascript both so i thought i would post here.

All i am trying to do is add



rel="lightbox[profile]"


Simple enough right, not so fast lol...

Here is what i know...

apicture holds the array of all the images for that member but there is no place in the class to add rel= to the tail end of the url..

i know that $url_src is the full size version of the image but again, no place to concatenate the rel= on the back end of that.


So your prob thinking ok why not just add rel= to the anchor tag line. My thought exactly which is how lightbox should work. The problem is if you look at the anchor tag below look for this

<!-- must use lightbox in this a tag -->

i have rel= there but its only pulling one sql array image value at a time, so the prev and next labels are not showing in lightbox because it thinks its the only image.

so i thought ok the show image function that is called below that anchor tag i can just add rel= there before the onclick. But again that does not work, it only shows two images plus the fact that when i click the arrows that it uses, it opens lightbox and thats not what i want. So then i thought ok i will attack tihs at the show image function itself and just concat the rel= on the tail end, but that dont work either..

What im trying to do is just use the anchor as normal that i have already but make it see there are more images. I thought about building a sep array
in the foreach and then using that, but then i lost my train of thought so i thought i would ask here.

normaly what i would do is in the foreach just make a new array and as it loops thru it builds the new array, then use that array for the anchor tag instead of sql array, the problem is that i get confused with the way it is now.
To me it is mixing the movement buttons with the bigpicture display with the show image function and its really blowing my mind.

Here is the code.




$aPicture=$picture->GetListByMember($USERID);
$no_of_pics = count($aPicture);


if ($no_of_pics > 0)
{
$pic_no=0;
foreach ($aPicture as $sql_pic_array)
{
$pic_no++;

if($show_private || $sql_pic_array->pic_private != 'Y')
{
$medium = $sql_pic_array->GetInfo('small');
$full = $sql_pic_array->GetInfo('');
$url_src .=",'$CONST_LINK_ROOT/includes$full->Path'";
$img_src .= ",'includes$medium->Path'";
$dimensions = "width='100' height='100'";
}else{
$img_src .= ",'$CONST_IMAGE_ROOT/EN$sql_pic_array->private_file'";
$url_src .= ",\"#\"";
$dimensions = "width=".CONST_THUMBS_MEDIUM_W;
}
}//close foreach

$loading_img_url = "$CONST_IMAGE_ROOT/$CONST_IMAGE_LANG/photo_loading.gif";

?>

<script language="JavaScript" type="text/javascript">

function show_image(name,name1,cur_image_num)
{
url = eval(name + '_img_src[' + cur_image_num + ']');
url1 = eval(name + '_url_src[' + cur_image_num + ']');
img = document.getElementById(name);
img.src = loading_img_url;
link_url = document.getElementById(name1);
link_url.href = url1;

if(<?=$no_of_pics?> > 1)
{
pic_caption = document.getElementById(name+'_caption');
pic_caption.innerHTML = cur_image_num + ' <?=ADVERTISE_PHOTO_NUM_OF?> <?=$no_of_pics?>';
}

window.setTimeout('document.getElementById(\'' + name + '\').src = \'' + url + '\'', 1);
}//close function show_image

mainpicture_img_src = new Array(0<?=$img_src?>);
mainpicture_url_src = new Array(0<?=$url_src?>);
loading_img_url = '<?=$loading_img_url?>';

imgLoading = new Image();
imgLoading.src = loading_img_url;

</script>

<tr>
<td class="normal" bgcolor="#FFFFFF" style="padding:10px 0px 10px 20px">

<!-- must use lightbox in this a tag -->
<a href="<?=$sql_pic_array->pic_picture?>" rel="lightbox[profile]" id="bigpicture">
<img src="<?=$loading_img_url?>?<?=time() ?>" class="imageframe" style="padding-right:5px" align="left" width="115" height="115" id="mainpicture" name='pic' border="0" alt="" /></a>

<?php
if ($no_of_pics >= 1)
{
?>
<a href="#" onClick="if (--cur_image_num&lt;1) cur_image_num=<?=$no_of_pics?>;show_image('mainpicture','bigpicture',cur_image_num)"><img src="<?=$CONST_IMAGE_ROOT?>/btn_previous.gif" border="0" /></a>

&nbsp;

<span id="mainpicture_caption"></span>&nbsp;

<a href="#" onClick="if (++cur_image_num&gt;<?=$no_of_pics?>) cur_image_num=1;show_image('mainpicture','bigpicture',cur_image_num)"><img src="<?=$CONST_IMAGE_ROOT?>/btn_next.gif" border="0" /></a>
<?php } ?>

<script type="text/javascript">
cur_image_num = 1;
show_image('mainpicture','bigpicture',cur_image_num);
</script>





Thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum