CI separately configure the site foreground background method

Source: Internet
Author: User

CI 2 Multi-directory (application) configuration.

Multi-directory means that there are many sets of programs in the same website, the simplest example is the site's foreground display and background management. Because they belong to different parts in the function of the website, they usually have different interfaces, and the images/stylesheet/javavascript is basically separate, so we set up different directories.


SOURCE download after extracting the file structure, such as, the default is only one directory.


In order to achieve multiple catalogs to share a codeigniter goal, we need to complete the following steps:

1, in the application directory under the new sub-directory admin, the red box labeled 5 folders under the admin. The function of these five folders is briefly described, detailed description can refer to CI official website:

Admin/config: Basic Configuration file

Autoload.php can set which class libraries are loaded by this directory program by default;

Config.php can set some global variables that are limited to this directory program;

Database.php can set the database connection (DSN) variable for this directory only program;

Routes.php can set the default load controller for this directory program.

Admin/controllers: Storing this directory controller

Admin/libraris: Store This directory CI class library

Admin/models: The model file to store this directory, this place is necessary to explain, usually the front desk background to the data table (table) is the same, but the basic operation of the data table is different, the current practice is to use the various parts of the common data model operations written as function to store , of course, does not rule out that two parts will have the same situation, such as can be custom method Get_all () to read all the data of the current model (table).

Admin/view: The view that holds this directory can be understood as page.

2, set the entry file. Because the root directory of the index.php default is to find the applcation under the controllers controller, in order to read the controller under the applcation/admin/controllers, we need to create a new admin file under the site root directory, and copy the index.php under the root directory here, and then edit this index.php to find:

$system _path = "System"; instead $system _path = "...  /system ", $application _folder=" Application "; instead $application _folder = "... /application/admin ";

In addition, this directory may be used in the Css/js/images folder can also be placed under the new admin.

The program directory structure at this time is as follows:


At this point, the first goal has been achieved, I put the default controller load two directory of the view to make a change, and now show you the results of our first goal.
Front desk:

Background:

CI separately configure the site foreground background method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.