Reputation: 251
I have pages with articles. When someone clicks on them from an outside source how can I make that article pop up in fancybox and have the index page as the parent page.
I have my pages set up in this format: pages.php?id=123
I want to open that link from my index.php with the fancybox already open to that link.
Upvotes: 2
Views: 920
Reputation: 13509
You can check the referrer on pages.php to see if it's from an outside source, and then redirect to the index page with something in the parameter (e.g. ?external=true;articleid=123) identifying that a Fancybox should pop up with the appropriate article.
For example, on pages.php:
$(function(){
if (document.referrer.indexOf(<your url>) < 0){
window.location = "index.php?external=true;article=123";
}
});
And then on index.php:
$(function(){
//Insert code here to parse query string. You can find code for this online.
var isExternal = getValueOfExternal();
var articleId = getValueOfArticleId();
if (isExternal){
//open fancybox
$.fancybox({
'href': 'pages.php?id=' + articleId
});
}
});
Upvotes: 1