简体   繁体   中英

How to use index.php?-url with colorbox

I got those php-urls like www.***.com/index.php?task=login .

My question is how can I use them with colorbox ? I'd like to load the content from the login page into my modal popup but I get unexpected results: it shows the complete website inside of the popup. How can I load the content into my modal popup properly when used with such URLs?

Currently my code looks like this:

$(document).ready(function(){
    $(".login_link").colorbox({

        href: "<?php echo $setting['site_url'];?>/index.php?task=login",

        onOpen: function(){
            $("#colorbox").css("opacity", 0);
        },
        onComplete: function(){

            var title = 'Login';
            $('#cboxTitle').text(title);
            $("#colorbox").animate({"opacity": 1});
        }
    });

Now we know that the reason why you see the whole site in the modal is because you are loading the whole site into it (nothing to do with parameters getting ignored), we need to look at how you might load just the component you want.

I assume you are using some kind of CMS framework? This may have a method built in to supply things like this (Joomla for instance allows you to add &tmpl=component to the url and it will magically deliver what you are asking for. I don't know what framework you are using so I cannot advise specifically. This will be the "proper" way to perform the task.

Now assuming the file /includes/misc/misc.inc.php is under your document root, you should be able to invoke it by using something like:

http://your.site.domain/includes/misc/misc.inc.php

as the url. HOWEVER!!!! This is unlikely to work. The chances are that other parts of the framework are instantiated by the calling of index.php, which will not happen if you call the include file directly. Indeed, unlike WordPress, Joomla has measures in place which prevent execution of any of its included files unless they have been invoked via index.php.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM