Home  >  Article  >  CMS Tutorial  >  dedecms custom content model on the homepage list page and how to call the tag in the content

dedecms custom content model on the homepage list page and how to call the tag in the content

藏色散人
藏色散人Original
2019-12-18 09:59:272830browse

dedecms custom content model on the homepage list page and how to call the tag in the content

dedecms Custom content model How to call tags on the homepage list page and content?

This article describes dedecms’ homepage, list page, and content calling methods for custom models (independent models). It is relatively simple to establish custom models (independent models) and add custom fields in the background. , two points need to be noted here:

Recommended learning: 梦Weavercms

1. If a field needs to be displayed on the front-end list page, check the box in the front-end parameters Select "Make the field available in the underlying template of the list (custom fields can only be displayed in the document template by default, but enabling this option will slow down the list query, please do not select it if necessary)";

2. The ID of the independent model must be set to a negative number, otherwise the data cannot be retrieved on the list page. This is considered a bug in dedecms. I originally planned to modify the list tag, but later I accidentally discovered that as long as the ID of the independent model is set to a negative number, it can be displayed normally.

After building the independent model and fields, the calling method on the website is as follows:

(1) Call the custom model (independent model) on the homepage:

Please call the independent model Use arclistsg independent single table model to call tags instead of arclist document list tags. Most of the tutorial articles on the Internet are for adding custom fields to existing models rather than creating new independent models, so independent models cannot be called using the arclist tag.

The code is as follows:

{dede:arclistsg typeid='8' row='10' addfields='name,sex,tel' channelid='-101' } 
[field:title/] 姓名:[field:name/] | 性别:[field:sex/] | 电话:[field:tel/]
{/dede:arclistsg}

To obtain the content of a custom field, two conditions must be met, one of which is indispensable:

1. Specify the channelid attribute. This is channelid. ='-101'

2. Specify the fields to be obtained addfields='Field 1, Field 2'

(2) The list page calls the custom model (independent model):

The code is as follows:

{dede:list pagesize='10' addfields='name,sex,tel' channelid='-101' }
[field:title/] 姓名:[field:name/] | 性别:[field:sex/] | 电话:[field:tel/]
{/dede:list}

If the column has content, but the list page does not fall out, it must be because the id of your independent model is not a negative number.

(3) The content page calls the custom field data of the custom model (independent model):

Write {dede:field.name/} directly where you want to call, where name Change to the name of the field you want to call.

The above is the detailed content of dedecms custom content model on the homepage list page and how to call the tag in the content. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn