Domanda

I am developing blog in codeigniter using tank authentication library(downloaded from net)

As you know blog contain like/dislike button .When click on like button(a view page) ,first control is transfer to controller where it is checked whether user is logged in or not,if user is logged in then control is transferred back to main blog page and blog is liked(ie like counter is incremented) but, if user is not logged in or is not the member of community then login/register form is displayed.

These all functionality is in-build in tank authentication library is it is working fine.

Problem: I want that if user is not logged in or is not a member ,then whichever page is displayed(login/register/forgot password/send email again),they should be opened in pop up on click of like/dislike button.

Work done: Used anchor popup function but no use. Result:It display view in new window

Placed the view of login/register form on same blog page,used jquery (fade in,fade out)etc function to display pop up. Result:pop up is displayed, but as that pop up is not coming from controller so is of no use.(as tank authentication library function are not getting envolved.)

So if possible then please help me to display view(called from controller as pop up). If possible then do send some proper links or any demo project. There is a function of jquery-fancy box,I guess that would work. I know the problem will be solved by applying concept of jquery+ mvc flow, but as I am new to php as well as codeigniter so I am not able to integrate my thoughts properly.

Thank you in advance.

È stato utile?

Soluzione

Use Fancybox your problem will be solved. [Download] the package first. Then include the CSS and JS in your template.1

Usage:

<a href="<?=base_url()?>home/login/" class="fancybox">Login</a>
$(function(){
    $(".fancybox").fancybox({
        type        : 'iframe',
        autoSize : false,
        width    : "60%",
        height   : "56%",
        'scrolling'     : 'no',
        'titleShow'     : false,
        openEffect  : 'fade',
        closeEffect : 'fade'
    });
});

EDIT
Changes :
added the fancybox class in the link.

<a href="<?php echo base_url()?>index.php/blog/ajax_dislike/?dislikeid=<?php echo $row ->id;?>" class="fancybox">Dislike</a>

Mandatory includes in the <head> section of the index page:

<script type="text/javascript" src="<?=base_url()?>js/jquery-1.9.1.js"></script>
<link rel="stylesheet" href="<?=base_url()?>css/fancybox/jquery.fancybox.css" />
<script type="text/javascript" src="<?=base_url()?>js/jquery.fancybox.js"></script>

Now in the page in the <head> section include this after the above includes:

<script type="text/javascript">
$(function(){
    $(".fancybox").fancybox({
        type        : 'iframe',
        autoSize : false,
        width    : "60%",
        height   : "56%",
        'scrolling'     : 'no',
        'titleShow'     : false,
        openEffect  : 'fade',
        closeEffect : 'fade'
    });
});
</script>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top