application/config/routes.php
$route['404_override'] = 'my404';
application/controllers/My404.php
output->set_status_header('404'); $data['content'] = 'error_404'; // View name $this->load->view('index', $data);//loading in my template } }
Knowledge should be free and accessible
application/config/routes.php
$route['404_override'] = 'my404';
application/controllers/My404.php
output->set_status_header('404'); $data['content'] = 'error_404'; // View name $this->load->view('index', $data);//loading in my template } }
On some hostings you can receive this error.
A PHP Error was encountered Severity: Warning Message: unlink(/tmp/ci_session0189a7f1c86eb18fb70afcfedc2d5040e9c23146): Operation not permitted Filename: drivers/Session_files_driver.php
To fix this go to application > config > config.php and edit this line:
$config['sess_save_path'] = BASEPATH . 'cache/';
In my practice there are two simple solutions.
0 0 1 * * php /home/USER/public_html/index.php NAME-OF-CONTROLLER NAME-OF-METHOD
example -> php /home/User/public_html/index.php TestCron index
0 0 1 * * curl –silent URL-OF-THE-SCRIPT
example -> curl –silent http://maratonkata.nikolaynikolov.net/TestCron
Download and extract codeigniter. In main folder create another folder named assets. There will be additional files for css, js and more.
Setup configuration files. Go to application/config:
– in autoload.php
$autoload['libraries'] = array('database','session'); $autoload['helper'] = array('url','form');
– in config.php
$config['base_url'] = 'http://www.example.com/'; $config['index_page'] = ''; $config['encryption_key'] = 'someEncryptionKey'; $config['sess_save_path'] = sys_get_temp_dir(); //Fix problems with session
– in database.php
'username' => 'root', 'password' => 'rootPassword', 'database' => 'DatabaseName',
– in routes.php
$route['default_controller'] = 'Main_controller';
Step 2 Create Main_controller file in application/controllers
Easiest way is to copy and rename Welcome.php
Step 3 Create .htaccess file in main folder. This is a must for routing!
RewriteEngine On RewriteCond %{HTTP_HOST} ^my-domain.com [NC] RewriteRule ^(.*)$ http://www.my-domain.com/$1 [L,R=301] RewriteCond %{THE_REQUEST} ^[A-Z]+\ /index\.php(/[^\ ]*)?\ HTTP/ RewriteRule ^index\.php(/(.*))?$ http://www.my-domain.com/$2 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [L]
In this tutorial we will implement multilanguage to CodeIgniter.
Site Default Language
Open the application/config/config.php file and specify the site’s default language.
$config['language'] = 'bulgarian'; //Language you want to be default
Language Files
The language files must be named with _lang suffix. For example, if you want to create a file containing site’s message translation then the file name might be message_lang.php.
Insert those files into the application/language/ directory with separate sub-directories for each language (for example, english, bulgarian, etc.).
Continue reading “Multilanguage CodeIgniter 3.0”