• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MY_Controller extension problem

#1
[eluser]jacobson[/eluser]
Hello, I have a problem with facebook. I want the "log in with facebook" button to be visible on all pages. This means that I need the whole code in controller/action related with facebook (about 20 lines).I wanted to put all of this into just one file. I wanted to use core extension My_Controller. I added all of this lines to __construct to My_Controller and added to my site_controlle to extend My_Controller but it's not working. Facebook is not visible :/ Am I doing something wrong ? is there any other possible solution for this problem ?

#2
[eluser]solid9[/eluser]
Don't add the 'FaceBook' login button codes in the _construct instead add it into your Header View.
By doing this it will show up to all of your pages.

Hope it will help you.

#3
[eluser]jacobson[/eluser]
earlier i had it on my index page only :

Code:
function __construct() {
        parent::__construct();
        $CI = &get;_instance();
        $CI->config->load('facebook', TRUE);
        $config = $CI->config->item('facebook');
        $this->load->library('Facebook', $config);
    }

Code:
public function index() {


        $user = null;
        $user_profile = null;

        $user = $this->facebook->getUser();

        if ($user) {
            try {
                $user_profile = $this->facebook->api('/me');
                $facebook_id = $user_profile['id'];
                $exists = $this->db->where('facebook_id', $facebook_id)->from('users')->count_all_results();
                if ($exists == 0) {
                    $first_name = $user_profile['first_name'];
                    $last_name = $user_profile['last_name'];
                    $link = $user_profile['link'];

                    $this->site_model->addUser($facebook_id, $first_name, $last_name, $link);
                }
            } catch (FacebookApiException $e) {
                $user = null;
            }
        }

        $data['facebook'] = $this->facebook;
        $data['user'] = $user;
        $data['user_profile'] = $user_profile;

        $data['news'] = $this->site_model->getNews();
        
        $data['main_content'] = 'main';
        $this->load->view('includes/template', $data);
    }

but I want to have it on all pages that's why I wanted to extend the controller.

#4
[eluser]solid9[/eluser]
oAuth 2.0


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.