Dede module MVC Framework basic description, zhimeng cmsv5.7mvc development framework

Source: Internet
Author: User

The weimeng MVC development framework is a simple and mini web development framework that can be used to compile the extension functions, modules (INS) based on the zhimeng content management system ), it can even be separated to develop blogs, BBS, SNS, etc.

Directory structure description:
| _ App
| ___ Control controller (c)
| ___ Model (m)
| ___ Templates view template (V)
| ___ Libraries class library
| ___ Data configuration
| ___ Data \ helper
| ___ Static style, JS, image folder
| ___ Index. php unified entry file

Unified entry resolution address
Http: // your url/APP/index. php? Ct = index & AC = save
Ct = index: controller entry, corresponding to index. php In the control directory
If runapp () specifies the third parameter, for example, runapp ($ CT, $ AC, 'admin') in the Q & A, it indicates Ct = index: controller entry, corresponds to the index in the control/Admin directory. PHP
AC = save: operation, corresponding to the function ac_save () in the class index in the file index. php ()
The Controller stores all related function operations in a file. For example, the message board can be used:
? Ct = guestbook & AC = {do} is uniformly completed, which facilitates static deployment.

1. Controller development instructions (Control ):
BasicCodeStructure:

 

Class yourctname extends control
{
Public Function ac_save ()
{

}
}

The controller can inherit a base class: control. The file name corresponding to this class is/include/control. class. PHP, which contains operation instructions for the base class. There are several common methods:

 

$ Control-> model ();
// Load a model. For example, $ this-> question = $ this-> model ('mquestion ') in index. php In the Q & A module loads the mquestion model. Then, we can call the corresponding model operations through $ this-> question. Insert and update data. The name of the call class can be defined at will, but there must be no conflict. The model file is placed in the model directory.

$ Control-> libraries ();
// Load a class. Sometimes we need a class that does not exist in the system for development, we can use this method to load a class of our own. The specific method is the same as the model. Class in the libraries directory.

$ Control-> helper ();
// Load a helper. The introduction of helper is to help us store and manage the functions we need.
The specific method is the same as the model. The Helper is stored in the data \ helper directory.

$ Control-> settemplate ();
$ Control-> settemplet (); // you can specify a template for the current operation;

$ Control-> setvar ($ K, $ V); // set the variables to be parsed in the template, and use {Dede: var. Name/} in the template for calling.

Globals ['K'] = $ K;
// Set the variables required by the template, which can be directly used in the template <? PHP echo $ K;?> Method output (the Q & A module basically uses this method for output). This method is suitable for processing complex data, such as arrays.

$ Control-> getvar ($ K); // get the preset template Variables
$ Control-> display (); // display the parsed content of the template
$ Control-> saveto (); // Save the content to a file

For more information about template usage in the controller, see the dedetemplate template engine. For details, see the template description section in the company's internal development documentation.

Model Development description ):

 

Class mtype extends Model
{
Public Function get_one ()
{

}
}

The controller can choose to inherit a base class: model. The file name corresponding to this class is/include/model. Class. php, which contains the operation instructions for the database class. Here there is only one method:
$ Model-> dsql ();
// Instantiate the database operation class.

 

Template tag call description:
If $ control-> setvar ($ K, $ V) is used in the controller, we call the parameter through the tag {Dede: var. Name.
If you use globals ['K'] = $ K in the controller, we use the tag {Dede: Global. name/} Method for calling or directly using PHP for output.

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.