Dede Module MVC Framework Basic description, Weaving Dream CMSV5.7MVC development Framework

Source: Internet
Author: User

Weave Dream MVC Development Framework is a streamlined, mini web development framework, using this development framework can be written based on the Dream Content Management system extension functions, modules (plug-ins), and even can be separated out to develop blogs, BBS, SNS and so on.

Directory Structure Description:
|_app
|___control Controller (C)
|___model Model (M)
|___templates View Template (V)
|___libraries Class Library
|___data Configuration
|___data\helper Little Helper
|___static style, JS, picture folder
|___index.php Unified Entry File

Unified Portal Resolution Address
HTTP.//Your URL/app/index.php?ct=index&ac=save
Ct=index: Controller entry, corresponding to index.php in the directory control
If RunApp () specifies a third parameter, such as Q/A RunApp ($ct, $ac, ' admin '), description Ct=index: Controller entry, corresponding to index.php in directory Control/admin
Ac=save: Action, corresponding to the file index.php in class index in function Ac_save ()
The controller will store related functions in a file, such as the message board, you can use:
Ct=guestbook&ac={do} is unified, which makes it easy to deploy statically.

1. Controller development Instructions (control):
Basic code structure:

Class Yourctname extends Control
{
Public Function Ac_save ()
{

}
}


The controller can choose to inherit a base class: control, this class corresponds to the filename is/include/control.class.php, which contains the base class related operation instructions, here are a few common methods:

$control->model ();
Load a model. For example, the index.php in the question-and-answer module $this->question = $this->model (' mquestion ') is loading the mquestion model. And then we can invoke the model by $this->question the corresponding action. Implementation of data insertion, update and so on. The name of the calling class can be arbitrarily defined, but ensure there is no conflict. The file of the model is placed in the models directory.


$control->libraries ();
Loads a class. Sometimes when we need a class that doesn't exist in a system, we can load one of our own classes with this method. The exact method is the same as the model. Class is placed in the Libraries directory.

$control->helper ();
Load a small helper. Small assistants are introduced to help us to store and manage the function we need to use.
The exact method is the same as the model. The small helper is placed in the Data\helper directory.

$control->settemplate ();
$control->settemplet (); Set the template to be specified for the current operation;

$control->setvar ($k, $v); Set the variables that the template needs to parse, and make calls using {dede:var.name/} in the template.

globals[' k '] = $k;
Set the template required variables, in the template can be directly used <?php echo $k; > Output (question and answer modules are basically output in this way), which is more suitable for dealing with complex data, such as arrays.

$control->getvar ($k); Get the Set template variable
$control->display (); Display the content of the template after parsing
$control->saveto (); Save content to a file

The use of the template in the controller can be referred to the dedetemplate template engine, in the company's internal development documentation for the relevant section of the template description.


Model Development Description:

Class Mtype extends Model
{
Public Function Get_one ()
{

}
}


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

Template Tag Invocation Description:
If the controller is passed $control->setvar ($k, $v); The parameters set in this way are called by means of the label {dede:var.name/}.
If in the controller through globals[' k '] = $k, the parameter set by this way, we call through the way of the label {dede:global.name/} or directly in the way of PHP output.

Dede Module MVC Framework Basic description, Weaving Dream CMSV5.7MVC development Framework

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.