(go) custom data model in DEDECMS

Source: Internet
Author: User

Just finished learning dedecms label Grammar, I have a lot of confusion, I think the meaning of the label is more abstract, do not know how to use the label to write some specific content. If you have some database programming experience, you will know a very common programming example-additions and deletions. For example, I want to build a book model, there are call numbers, titles, types ..., and then to write a Web page to complete the book information additions and deletions, this article mainly solves this problem.

One channel (content model)

I can't figure out the difference between the channel and the column for a long time. From the Internet to find some explanations are as follows:

column is the site navigation division of the module, such as Baidu in the news, Web pages, bar paste, etc. is the column.

The channel is the type of the column. The official definition is: Channel refers to the content model, the site's columns are based on different models of the establishment. That means a channel can also be derived from a number of columns, a column only corresponds to a channel.

After checking the above definition, I thought the channel and the column already had the deeper understanding. Until I met this question, " when to set up the channel, when to set up the column ?" ”

The channel corresponds to the data model, and when a new data model is created, a channel is established. such as book model, it and the article model, Picture Model data table structure is different. A new model has the following elements: data tables, additions and deletions, and code changes.

and the column is corresponding to the function, like Baidu in the news, Web pages, paste, when to add columns or more obvious. 3 Types of templates belong to the elements of the column.

"A channel can also be derived from a number of columns," the sentence is a bit empty, the actual content of the page is very full, the content of each column may be very different, in addition to practical article model, basic each channel for a column and set.

In Dedecms, there are several basic units of channels > Columns > Articles. Each unit will be uniquely identified by ID number, channel (Cid,channel ID), column (Tid,type ID), article (aid,article ID).

Two add models

To add a model, you might want to look at this article. It mainly tells the operation procedure, I will combine the operation to speak the principle. As mentioned above, a model has data tables, additions and deletions to change the code of the two elements, following the idea of development.

Click on "Add New Model", you will see the form of additional tables , fill dede_addonxx,xx is the first name identified. Dedecms articles do not refer to specific articles, more like records. Channel, an uploaded image is an article. So an article consists of two parts, one is the basic information, such as author, release time, etc., recorded in dede_archives, this table is called the main table. Each channel of the article information, there are additional tables, the additional table of the channel is dede_addonimages.

By the way, there is an option to have a standalone model in the nature of the model, that is, in the newly created model, the article is not documented in Dede_archives. It is possible to see too many extra fields in the dede_archives, which are not required for each model. The independent model is called the Single-table model, the abbreviation is SG, has the specialized sgarclist. Now just touch, ignore it first.

After the "Add New Model" form is submitted, you will see a dede_addonxx table in the database, so don't be anxious to define the table's fields, because Dedecms will assist us with this process.

Now around the 3rd of this article, go to content Model Management >dede_addonxx Modify > Field management > Add New field to add fields to dede_addonxx. Once you've added a field submission, you'll go back to the field management page and see "model field Configuration," a label that represents the process you just defined, which is not a manual definition of a database table. In summary, it is better to add a new field to the attached table with this method.

The code to change and delete, in the previous file release/modification/management has been defined. At first, use archives_add.php,archives_edit.php and content_list.php. Since Dedecms has automatic form function, this file is basically enough. The automatic form means that the fields that were set when the new field was added earlier appear as controls in forms such as add,edit, without requiring the user to add code. If you do not feel enough, you can refer to archives_add.php and other DIY.

This custom channel can be used to generate columns, as well as the default columns.

For additions and deletions, this may only be the main model of the building, for the auxiliary model can also refer to other background management code, such as the classification information model, add a regional table. It takes a while to make sense of background management.

Addition and deletion of the function is not limited to the backstage, the front desk also has these features. The front desk will not be able to use the form of such a rigid submission, may need to use Ajax. can refer to the system top-stepping function and the implementation of the comment function.

Three using the data in the model

Addition and deletion after the remaining check, this feature is not required to fill out a lot of forms. The query of the data is generally done with the label, and the field,arclist,list and its derivative tags have covered a lot of situations.

In the article template, you can query the fields of the attached table with the field tag, and in the list template, you can also query the fields of the attached table by Arclist, as follows:

<tr>
{dede:arclist addfields= ' sjdz,yysj ' channelid= ' 1}
<td> Business Address:[field:sjdz/]</td>
<td> Business Hours:[field:yysj/]</td>
{/dede:arclist}
</tr>

The key is that AddFields and channelid,addfields inside is your custom field, channelid if it is a normal article is 1

Of course there are a lot of things that are not enough to customize the label. You can look at the following articles: Article 1, article 2

(go) custom data model in DEDECMS

Related Article

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.