Force lightbox to open in parent page php JavaScript
Question by user1434701
Yet another newbie asking for help.
I have a Main_index.php page. Multiple divs are loaded into this page and each div has a “More” information button. Each div is a template style and is completed with mysql data.
<div class="more"><a href="advert_details.php?advert_id=<?php print $advert_id?>"id="more<?php print $advert_id?>"><?php echo MORE ?></a></div>
Each “More” button brings up a new page “advert_details.php”, inside a lightbox. This is again a template style and loads details from mysql. The lightbox code is in the Main_index.php.
<script language="JavaScript" type="text/javascript">
$(document).ready(function()
{
$('a').filter(function() {
return this.id.match(/more[0-9]/);
}).fancybox({
'overlayColor' : '#000',
'overlayOpacity' : 0.1,
'width' : 640,
'height' : 940,
'type' : 'iframe'
});
});
</script>
If one of the “advert_details.php” pages is found by a search engine, when you click on the search result, the lightbox opens in a blank page.
Is there anything I can add, to force the “advert_details.php” page to open in the “main_index.php” page, making use of the lightbox JavaScript and showing the main site page?
I hope that I have explained this well, if not, please ask for more details.
Thanks
Peter
Answer by Starx
You can set a URL parameter which will be checked to include the advert_details.php
in the main page.
Something like
if(isset($_GET['showDetails'])) {
include "advert_details.php";
}