Tuesday, March 13, 2012

WelCome Page Of Codeigniter Details


1)      To edit the code use an editor.
2)      I will use Dream-weaver.
3)      Now open the welcome.php file from the directory …/xampp/htdocs/mysite/application/controllers/
4)      If you read the default code please don’t ignore the code under the comments.
a)      As a fresher you must read at least the following lines:
* Since this controller is set as the default controller in
* Config/routes.php.

This is the main reason for showing the default welcome page after fresh installation.
Now open the routes.php file from the directory:
..Xampp/htdocs/mysite/application/config/
Now go to the line number 41 where the following line is appeared:
$route['default_controller'] = "welcome";
It means that after loading a fresh installation the welcome controller will load first.
b)      Now read another  two lines of comments:
* Maps to the following URL
*http://example.com/index.php/welcome
*- or - 
*http://example.com/index.php/welcome/index
As we have named our site mysite so if we can get welcome page by writing the URL three types:
Interesting to say after writing the three URL individually we will get same output.
In the above three example Codeigniter would attempt to find a controller named welcome.php and load it. When a controller’s name matches the first segment of a URI, it will be loaded.
5)      Now back to the welcome.php file of controller directory. Let’s analyze the other lines step by step:
a)      Class names must start with an uppercase letter. As the class is welcome so it starts with the Uppercase letter named Welcome
b)      Under the class Welcome there is a function named index (). The index function is always loaded by default if the second segment of the URI is empty.
c)       Under the function index() there is a call to load the welcome_message.php  from the view folder.
6)      Now open the welcome_message.php from the directory …/application/views/ if you open the welcome_message.php you will get some html code.

The final result is in the welcome message of Codeigniter.

No comments:

Post a Comment