PHPCMS v9 Column list call each article content Method 1

Source: Internet
Author: User

Let's take a look at the code of the default column call:


Copy the Code code as follows:
{pc:content action= "lists" catid= "$catid" num= "order=" "id DESC" page= "$page"}
<ul class= "list lh24 F14" >
{Loop $data $r}
<li><span class= "RT" >{date (' y-m-d h:i:s ', $r [inputtime])}</span> <a href= "{$r [url]}" target= "_ Blank "{Title_style ($r [style])}>{$r [title]}</a></li>
{if $n%5==0}<li class= "Bk20 hr" ></li>{/if}
{/loop}
</ul>
<div id= "pages" class= "text-c" >{$pages}</div>
{/PC}

As you can see, this is called the article title, URL, publish time, list paging, then how to call the article content?

In this case, is it possible to use moreinfo= "1" and then call {$r [content]} inside loop? The answer is no, because look at the database structure to know: the content and title are not in a table side, so cannot be adjusted out.
Look at the following calling code method:


Copy the Code code as follows:
{pc:content action= "lists" catid= "$catid" num= "order=" "id DESC" page= "$page" moreinfo= "1"}
<ul class= "list lh24 F14" >
{Loop $data $r}
<li><span class= "RT" >{date (' y-m-d h:i:s ', $r [inputtime])}</span> <a href= "{$r [url]}" target= "_ Blank "{Title_style ($r [style])}>{$r [title]}</a>
<?php $id = $r [' id '];
$sql = "Select ' content ' from ' cmsyou_news_data ' WHERE ' id ' = ' $id ' LIMIT 0, 1";
$query = mysql_query ($sql);
while ($row =mysql_fetch_array ($query)) {
echo $row [content];
}
?>
</li>
{if $n%5==0}<li class= "Bk20 hr" ></li>{/if}
{/loop}
</ul>
<div id= "pages" class= "text-c" >{$pages}</div>
{/PC}

Where the following code calls the corresponding content:


Copy the Code code as follows:
<?php $id = $r [' id '];
$sql = "Select ' content ' from ' cmsyou_news_data ' WHERE ' id ' = ' $id ' LIMIT 0, 1";
$query = mysql_query ($sql);
while ($row =mysql_fetch_array ($query)) {
echo $row [content];
}
?>

is to invoke the corresponding ID content of the specified data table directly with SELECT. We do not put extrapolate, do more to try! There are different ways to welcome the message to discuss!

PHPCMS v9 Column list call each article content Method 1

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.