Home  >  Article  >  CMS Tutorial  >  How to call content in phpcms

How to call content in phpcms

藏色散人
藏色散人Original
2020-01-08 10:39:212462browse

How to call content in phpcms

How to call content in phpcms?

How to call the content of a single article on the home page of phpcms

In fact, there are many solutions to using phpcms to call the content of a single article on the home page list page. We can copy the content directly instead of using the program to automatically call it. However, if there are many repeated operations, there will be certain cumbersome locks. In addition, we can list the tag {pc:content} to implement automatic calling.

Two implementation methods introduced to you.

Analysis of ideas for calling internal page article content on the home page

Reminder: Starting from PHPCMS V9 Beta 20101105 version, the moreinfo parameter attribute is supported. This parameter indicates that when returning data, The data in the secondary table will also be returned together. A content model is divided into two tables, a main table and a sub-table. The main table generally stores short data such as titles and columns (convenient for indexing), while the sub-table stores data in large fields. Data such as content. When you create a new field in model management, you are allowed to choose whether to store it in the main table or the secondary table (we recommend putting unimportant information in the secondary table).

If you want to retrieve the data of the secondary table in the list, you need to use the moreinfo attribute in the PC tag. But we only call a fixed article on the homepage instead of using it in large quantities, which is still acceptable for performance. Here are two ways to do this.

Method to implement the content of a single article

Method 1:

Use {pc:content action="lists"} basic tags to implement a list, each List items are all called content. If you only want to call the content of a certain article, change num="4" to num="1". The called article is the first or last article, and pass order="id DESC or order="id" To adjust.

<div>
{pc:content  action="lists" catid="6" order="id DESC" num="4" moreinfo="1"}
    <ul>
    {loop $data $key $val}
        <li>
            <a href="{$val[&#39;url&#39;]}">{$val[&#39;title&#39;]}</a>
            <div>
                {$val[&#39;content&#39;]}
            </div>
        </li>
    {/loop}
    </ul>
{/pc} 
</div>

Method 2:

Use the extended {pc:content action="lists"} tag to call the internal page article content of the specified article ID. You need to use the where attribute to Specify the article ID value to be called. This implementation method is more flexible, but slightly more complicated than the first one.

<div>
{pc:content  action="lists" catid="6" where="`id`=3" num="1" moreinfo="1"}
    <ul>
    {loop $data $key $val}
        <li>
            <a href="{$val[&#39;url&#39;]}">{$val[&#39;title&#39;]}</a>
            <div>
                {$val[&#39;content&#39;]}
            </div>
        </li>
    {/loop}
    </ul>
{/pc} 
</div>

PHP Chinese website, a large number of free PHPCMS tutorials, welcome Online Learning!

The above is the detailed content of How to call content in phpcms. 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