Bootstrap is a CSS framework that is popular in web development. Even Petanikode templates are also made with Bootstrap.
In this tutorial, we will not discuss bootstrap in detail. Because I've made a bootstrap tutorial in a different article.
If you don't understand bootstrap ...
... calm down, just follow this tutorial while studying.
Later you will understand yourself, hehehe.
Continue ...
Why SB Admin?
Steps that must be done to use bootstrap (SB Admin template) on Codeigniter:
- Codeigniter configuration;
- Download SB Admin;
- SB Admin Extract;
- Copy the file assets needed;
- Making Templates;
- Make a partial template;
- Use partial on the template;
- Finish ...
It sounds easy, but in practice, we will get many obstacles and problems.
Therefore, make sure you follow this tutorial carefully.
1. Initial Codeigniter Configuration
Before starting to create a template, please configure it first ...
Base URL configuration
Base URL serves to determine the address or URL that will be used by the web.
When developing the web, we will use the following Base URL:
http://localhost/tokobuah
This is the address that we can access from
localhost
.
When the web has finished, then change the address to the domain address.
Example:
https://www.petanikode.com
How to set the Base URL, please open the file
config/config.php
. Then fill in the section$config['base_url'] = '';
like this:Configure Autoload
Next we have to load a helper into memory automatically through
autoload.php
.
Helper is a Codeigniter function that will help us in various ways, such as: creating forms, accessing URLs, etc.
One of the helper we need in making templates is a helper
url
.
Helper
url
contains functions for accessing a URL such as base_url()
, site_url()
,$this->uri
, etc.
How to activate the helper
url
:
First open the file
config/autoload.php
, then search $autoload['helper']
. Add url
, so that it looks like this:Making Constants
After that, create a constant
SITE_NAME
to save the web name. We will need this constant to retrieve the web title in the template.
If you don't understand about constants in PHP, please read:What are Constants?
Continue ...
Please open the file
config/constants.php
, then add the following code .../*
|--------------------------------------------------------------------------
| Constants for Site
|--------------------------------------------------------------------------
|
*/
define('SITE_NAME', 'Tokobuah');
... at the end:
2. Download and extract SB Admin
After that, we will get a ZIP file. Extract the file so we have an admin SB file like this:
This is the template file that we will use on the Codeigniter project.
3. Adding the SB Admin in Codeigniter
Our next task is to add the SB Admin file to the Codeigniter project.
How:
We just need to copy / paste the files and folders needed. Here is the folder that we must copy :
- Folder
css
- Folder
js
- The
vendor
–rename folder becomes–>assets
For folders
vendor
, we will rename it assets
in order to not interfere with the folder vendor
of the composer .
Folders
vendor
contain front-end libraries from third parties, such as: Bootstrap, awesome fonts for icons , chart.js, datatables, and jquery.
However, because we will only use it. We just copy the three folders.
After that, we can start creating templates for admin views.
Please continue ...
0 Komentar untuk "Tutorial Codeigniter # 3: How to Use Bootstrap on Codeigniter"
Silahkan berkomentar sesuai artikel