diff --git a/www/application/config/config.php b/www/application/config/config.php index ee3d60a..0a94a4e 100755 --- a/www/application/config/config.php +++ b/www/application/config/config.php @@ -23,7 +23,7 @@ | a PHP script and you can easily do that on your own. | */ -$config['base_url'] = 'http://twitter-clone.lndo.site/'; +$config['base_url'] = 'http://' . $_SERVER['HTTP_HOST'] . '/'; /* |-------------------------------------------------------------------------- diff --git a/www/application/controllers/All_Tweets.php b/www/application/controllers/All_Tweets.php index 4e32d65..df80855 100644 --- a/www/application/controllers/All_Tweets.php +++ b/www/application/controllers/All_Tweets.php @@ -7,13 +7,14 @@ function __Construct(){ parent::__Construct (); $this->load->database(); // load database $this->load->model('All_Tweets_Model'); // load model - $this->output->enable_profiler(TRUE); + //$this->output->enable_profiler(TRUE); } public function index() { $this->data['posts'] = $this->All_Tweets_Model->getPosts(); // calling Post model method getPosts() $this->load->view('templates/header', NULL); + $this->load->view('templates/nav', NULL); $this->load->view('home', $this->data); // load the view file , we are passing $data array to view file $this->load->view('templates/footer', NULL); } @@ -22,9 +23,10 @@ function search_keyword(){ $keyword = $this->input->post('keyword'); $data['results'] = $this->All_Tweets_Model->search($keyword); - $this->load->view('templates/header'); + $this->load->view('templates/header', NULL); + $this->load->view('templates/nav', NULL); $this->load->view('home', $data); // load the view file , we are passing $data array to view file - $this->load->view('templates/footer'); + $this->load->view('templates/footer', NULL); } } diff --git a/www/application/controllers/Login.php b/www/application/controllers/Login.php index bd765d0..260b5b0 100644 --- a/www/application/controllers/Login.php +++ b/www/application/controllers/Login.php @@ -13,12 +13,16 @@ public function index(){ $this->load->helper(array('form', 'url')); $this->load->library('form_validation'); + $this->form_validation->set_error_delimiters('', ''); $this->form_validation->set_rules('username', 'Username', 'required'); $this->form_validation->set_rules('password', 'Password', 'required'); - if ($this->form_validation->run() == FALSE) + if ($this->form_validation->run() == FALSE){ + $this->load->view('templates/header'); $this->load->view('login'); + } + // load the homepage if login successful // https://www.codeigniter.com/user_guide/libraries/form_validation.html#callbacks-your-own-validation-methods @@ -35,7 +39,10 @@ public function index(){ redirect('/User_Tweets'); } // if no, refresh login - else $this->load->view('login', $data); + else { + $this->load->view('templates/header'); + $this->load->view('login', $data); + } } } diff --git a/www/application/controllers/Register.php b/www/application/controllers/Register.php index f8ff82b..603ce97 100644 --- a/www/application/controllers/Register.php +++ b/www/application/controllers/Register.php @@ -5,7 +5,7 @@ function __Construct(){ parent::__Construct(); $this->load->database(); // load database $this->load->model('User_Info_Model'); // load model - $this->output->enable_profiler(TRUE); + //$this->output->enable_profiler(TRUE); } public function index(){ @@ -22,8 +22,10 @@ public function index(){ array('required' => 'You must provide a %s.')); $this->form_validation->set_rules('email', 'Email', 'required|valid_email'); - if ($this->form_validation->run() == FALSE) - $this->load->view('register'); + if ($this->form_validation->run() == FALSE){ + $this->load->view('templates/header'); + $this->load->view('register'); + } // load the homepage once properly submitted // https://www.codeigniter.com/user_guide/libraries/form_validation.html#callbacks-your-own-validation-methods diff --git a/www/application/controllers/Tweet.php b/www/application/controllers/Tweet.php deleted file mode 100644 index 6f8945d..0000000 --- a/www/application/controllers/Tweet.php +++ /dev/null @@ -1,29 +0,0 @@ -load->database(); // load database - $this->load->model('User_Tweets_Model'); // load model - $this->output->enable_profiler(TRUE); - } - - public function index(){ - $this->load->helper('form'); - $this->load->library('form_validation'); - - $data['title'] = 'Create a tweet'; - - $this->form_validation->set_rules('tweet', 'Tweet', 'required'); - - if ($this->form_validation->run() === FALSE) - { - $this->load->view('tweet', $data); - } - else - { - $this->User_Tweets_Model->addTweet(); - $this->load->view('formsuccess'); - } - } -} diff --git a/www/application/controllers/User_Tweets.php b/www/application/controllers/User_Tweets.php index 6774e60..29eff36 100644 --- a/www/application/controllers/User_Tweets.php +++ b/www/application/controllers/User_Tweets.php @@ -7,12 +7,14 @@ function __Construct(){ parent::__Construct(); $this->load->database(); // load database $this->load->model('User_Tweets_Model'); // load model - $this->output->enable_profiler(TRUE); + //$this->output->enable_profiler(TRUE); } public function index() { + // get posts based on user ID $this->data['posts'] = $this->User_Tweets_Model->getPosts(); // calling Post model method getPosts() $this->load->view('templates/header', NULL); + $this->load->view('templates/nav', NULL); $this->load->view('user', $this->data); // load the view file , we are passing $data array to view file $this->load->view('templates/footer', NULL); } @@ -26,6 +28,7 @@ public function create(){ { $this->data['posts'] = $this->User_Tweets_Model->getPosts(); // calling Post model method getPosts() $this->load->view('templates/header', NULL); + $this->load->view('templates/nav'); $this->load->view('user', $this->data); // load the view file , we are passing $data array to view file $this->load->view('templates/footer', NULL); } diff --git a/www/application/views/home.php b/www/application/views/home.php index 85c8318..820fcf7 100644 --- a/www/application/views/home.php +++ b/www/application/views/home.php @@ -13,21 +13,30 @@