Difference between revisions of "Code Igniter"
From KOP KB
(→Making Sure your errors get properly styled) |
(→Auth Related) |
||
Line 24: | Line 24: | ||
Source: | Source: | ||
http://stackoverflow.com/questions/18903315/redirect-to-previous-page-after-login-ion-auth-codeigniter | http://stackoverflow.com/questions/18903315/redirect-to-previous-page-after-login-ion-auth-codeigniter | ||
+ | |||
+ | === Checking Certain parts about someone being logged in === | ||
+ | Simple syntax to check whether someon is logged in using Ion Auth. | ||
+ | <syntaxhighlight lang="php"> | ||
+ | if($this->ion_auth->logged_in()) //they are logged in | ||
+ | if(!$this->ion_auth->logged_in()) // not logged in | ||
+ | if($this->ion_auth->is_admin()) // They are logged in as admin | ||
+ | if($this->ion_auth->in_group("groupname"))// They are logged in to specified group | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | Source: John S. | ||
== Error Related == | == Error Related == |
Revision as of 14:00, 22 May 2015
Contents
Route Related
Forcing traffic to specific controller and method
Pretty much what were trying to do is make this url:https://www.domain.com/home/pages/aboutBecome This one:
https://www.domain.com/about
In the routes file below put in:
$route['default_controller'] = 'home/pages';
$route['(:any)'] = 'home/pages';
Auth Related
Ion-Auth redirect back to original page
Somone goes to said controller and needs to login to it the get forced to the auth page:
example.com/index.php/dashboard
To make it go back there you need to put the following in the auth controller were you see comments to that says login sucessfully
redirect($this->session->userdata('refered_from'),"refresh");
Checking Certain parts about someone being logged in
Simple syntax to check whether someon is logged in using Ion Auth.
if($this->ion_auth->logged_in()) //they are logged in
if(!$this->ion_auth->logged_in()) // not logged in
if($this->ion_auth->is_admin()) // They are logged in as admin
if($this->ion_auth->in_group("groupname"))// They are logged in to specified group
Source: John S.
Error Related
Making Sure your errors get properly styled
I am not sure how this will apply to other people but pretty much is at the top of all my error screens so that the css can always be called correctly. Granted its an error page but make your errors look god damn fantastic.
defined('BASEPATH') OR exit('No direct script access allowed');
// get the path to where you are
$url = $_SERVER['REQUEST_URI'];
//count the forward slashes
$count = count_chars($url, 1);
$urlcount = "";
//Take what you counted and make the path
// 47 I believe is the ascii code for / so therefore it counts those to determine how far down
for ($x = 1; $x < $count[47]; $x++) {
$urlcount = "../" . $urlcount;
}
//More or less this if and else statement is for the top directory and changes the string as necessary
if ($urlcount != null){
}else{
$urlcount="./";
}