Showing posts with label Codeigniter. Show all posts
Showing posts with label Codeigniter. Show all posts

How to load File.php to Index on Codeigniter

We previously have discussed about how to use codeigniter Easily. Now we will discuss about syantax php to load the php files into the mainpage. I'll explain a little bit the function of codeigniter. codeigniter useful to allow users to build a website with php files. One of the function codeigniter is a load php files on directory "view" into mainpage or we can say index.php. index only do loading conten from directory "view" so when index.php is executed on browser. it just refreshes  content with no background. so any profits faster loading due to load only on the content. Least one function that I know of codeigniter. back to the php syntax to load the main page or index. php syntax please see below


See the following Code here :
<?php if (!empty($page)): ?> <?php $this->load->view($page); ?> <?php else: ?> <?php $this->load->view('error_page'); ?> <?php endif; ?>

Explanation of the above code is as follows :

syntax "page" is useful to give the declaration on the directory "controllers" then please create a file with a name error_page.php to refine the code above
  • You should put it on a page of content that you created in index.php. Please see the picture below 


Then please go to the directory controller. as did the declaration of the previous article I explained how to use codeigniter Easily to set of  declaration.

How to add CSS, javascript, IMages to Codeigniter

I previously discussed about How to Use CodeIgniter Easily, from previous articles we've been getting a little technique to run CodeIgniter. This occasion I will try to share about how to add javascript files, css or images in codeigniter, This article will also discuss how to put css , javasrcipt, drawing to the main page in codeignitur. several steps that must be executed..

  • The first open the codeigniter that you've downloaded, then create a directory on pages outside of codeigniter file, silahan see in the picture below
  • In the picture above I created a directory named "public" in public directory please input files in addition to file format. php like css, javascript or image see the following picture :
  • Next we will try to edit the main page to provide links css, image or JS that you created earlier to the main page. See the following picture :

<link href="http://localhost/ajonk1/public/css.css" 

<td width="233" valign="top"><img src="http://localhost/ajonk1/public/images/index_03.gif" 
src="http://localhost/ajonk1/public/images/index_04.gif" 



How to Use Codeigniter Easily

This is my first article. actually very difficult for me to make the original conten rather than editing or copy and paste, but by the demands of love google I have made ​​my original content. I am not here to explain what it codeigniter? but I'll share some tips for you all to use and edit the most important parts in codeigneter. please follow the following steps:

  • First of all for those who do not have codeigniter, feel free to download on the official site codeigniter Here
  • Then after downloading codeigniter, you will find some files from CodeIgniter please see the following picture


  • Then you go to the application folder, you will find several folders. you will find two folders are "views" and "controllers". these folders are most decisive in codeigniter in the run.  Please see the following picture 
  • Then we will try to edit 2 folder, then you will be able to use codeigniter well, first we will edit the folder "view". view serves as a directory where the  php  files are put. See the following picture  

  • Then there are some pictures that I circled. This image became my main page. index1.php as the main page for the form user and index2.php as the main admin page for the form. same as the usual functions of index.
  • The following syntax to load the php file on the main page of "index1.php"
<?php if (!empty($page)): ?>
<?php $this->load->view($page); ?>
<?php else: ?>
<?php $this->load->view('error_page'); ?>
<?php endif; ?>
For an explanation of above syntax will be explained in a later article 
  • Then we will edit the folder "controllers". function of This folder as the page controller page. or we can define as identifier pages that we have put the folder "View".
  • Then in the directory "controllers" there is file named welcome.php image above is for mengidentifer edit multiple files. php that exist in the directory "Views"
a brief description of the above syntax:
public function index ()
{
$ data = array ('title' => 'Home', 'page' => 'home', 'login' => 'login');
$ this-> load-> view ('index1', $ data);
}
Home above identity of home.php is located in the directory "view"then "page" is used identifier to link to the index menuthen all the php file that will be loaded on the main page of "index1.php" And so on for multiple syntax identifier such as the step above 

Download template tutorial that I used will follow
The next page will explain how to add and edit the css file, javascript and images in codeigniter
 
Protected by Copyscape Duplicate Content Software