CakePHP / Facebook插件 - 链接到#的注销按钮

I'm attempting to use the Facebook plugin with CakePHP - all seems like it's going well - I can use the like/recommend buttons - I can login via facebook - it asks for permission for things that I told it to...etc

The problem is, my LOGOUT button just links to whatever page you're on plus a #

So - if I'm on index.php, the logout button links to index.php#

I AM including the correct facebook html tag and init() in the correct locations.

Any thoughts?

Here is my code for the logout button:

if(!$session->check('Auth.User.id') && !$this->Connect->user('id')) {
    echo $this->Html->link('LOGIN', array('controller' => 'users', 'action' => 'login'));
} else {     
    echo $facebook->logout(array('redirect' => array('controller'=>'users', 'action'=>'logout'), 'label' => 'LOGOUT'));
}

EDIT

And to be clear - I wouldn't care if the link is a #, but the logout button does nothing at all except bump the browser up to the top. It doesn't log out, it doesn't refresh the page.


EDIT2

If I start a fresh browser, login into Facebook, then go to my site, it auto-logs me in - at that point, the logout button works perfectly. But - if I log-in via a user-login on my site (instead of FB), the logout button just pops me to the top of the page (ie - the empty anchor link)

The link should be generated as a "#". The logout function generates this link with a javascript onclick event, which makes the call to FB and logs the user out. I would check if you're getting javascript errors. You reference the source code for confirmation.

I am currently dubugging the same problem (plus 1 other), and what I have found is that the FacebookHelper.php seems to handle $options incorrectly:

if((isset($options['redirect']) && $options['redirect']) || $options['custom']){
            $options['redirect'] = Router::url($options['redirect']);
            $onclick = "logout('".$options['redirect']."');";
            if(isset($options['confirm'])){
                $onclick = 'if(confirm("'.$options['confirm'].'")){'.$onclick.'}';
            }
            if($options['img']){
                $source = '/Facebook/img/'.$options['img'];
                return $this->Html->image($source, array(
                'alt' => $options['alt'],
                'id' => $options['id'],
                'url' => '#',
                'onclick' => $onclick));
            }
            else {   /* HERE  */
                return $this->Html->link($options['label'], '#', array(
                    'onclick' => $onclick, 'id' => $options['id']));
            }
        } else {
            $source = '/Facebook/img/facebook-logout.png';
            return $this->Html->image($source, array(
                'alt' => 'Facebook logout',
                'url' => '#',
                'id' => $options['id'],
                'onclick' => 'logout();'));

I'm not very expert in PHP, and could be wrong, but it seems that if $options are populated e.g. redirect, but no img param, then no button appears on screen (it goes to 'HERE'). By changing the code above, I can get then face book link displayed and the FB logout works. Now I' debugging an Auth prob where sessions keep regenerating after logout (with no FB connection).

My 'fixed code', still WIP and ugly is:

if((isset($options['redirect']) && $options['redirect']) || $options['custom']){
                    debug($options);
        $onclick = "logout('".$options['redirect']."');";
        if(isset($options['confirm'])){
            $onclick = 'if(confirm("'.$options['confirm'].'")){'.$onclick.'}';
        }
        if($options['img']){
            $source = '/Facebook/img/'.$options['img'];
            return $this->Html->image($source, array(
            'alt' => $options['alt'],
            'id' => $options['id'],
            'url' => '#',
            'onclick' => $onclick));
        }
        else {
                        //Yes it gets here!
                        $source = '/Facebook/img/facebook-logout.png';
                        $redirect=$options['redirect'];
                        return $this->Html->image($source, array(
            'alt' => 'Facebook logout',
            //'url' => '#',
                            'url' => $redirect,
            'id' => $options['id'],
            'onclick' => "logout('$redirect');"));
        }
    } else {
        $source = '/Facebook/img/facebook-logout.png';
        return $this->Html->image($source, array(
            'alt' => 'Facebook logout',
            'url' => '#',
            'id' => $options['id'],
            'onclick' => 'logout();'));
    }
}

`