PHPCMS-V9---How do I get the full-site article content via the {PC} tab?

Source: Internet
Author: User

1.phpcms-v9 By default, you can only get the current column and sub-columns under the CATID, but sometimes we need to use the {PC} tag to get the content of the entire site, what should be done?

The first step: Add the following method to the content_tag.class.php file:

1 /**2 * List page Label: The main return is the data in the main table and the data in the schedule3 * @param $data4      */5      Public functionLists_all ($data) {6         $this->db->set_model (1);//manually specify the model as the article model, why?  Because according to the source code routines, the model ID is set according to CATID, but now get all the article, not limited to a column, so can only manually set it as the article Model 1//According to the model ID to get the Model table and data table 1: Document Model-news 3: Picture model-picture 2: Download model-download7         if(isset($data[' WHERE ']) {//if the Where property is set in the PC label, there is no general case8             $sql=$data[' WHERE '];9}Else{//if the Where property is not set in the PC tabTen             $thumb=intval($data[' Thumb ']) ? "and thumb! =" ":";//If you have a thumb property One             $sql= "status=99".$thumb;//Remove the CATID condition//If there are no sub-columns under the current column A         } -         $order=$data[' Order '];//the Order property in the PC tab - //$sql appear as a condition, call the Select method in the Model.calss.php file, return the result set array, and sort by key name ' ID ' the         $return=$this->db->select ($sql, ‘*‘,$data[' Limit '],$order, ' ', ' id ');//Gets the primary table data from the database, and also uses the SQL statement query -     - //If you need to display the category name in the foreground, you can add the following code -     +         $TYPES= GetCache (' type_content ', ' Commons ');//Gets the category cache file, which caches all information related to category information -         foreach($return  as $key=$v) { +             $return[$key][typename]=$TYPES[$v[' typeID '] [Name];//Append a category field to each article in $return A         } at         //echo "<pre>"; - //print_r ($return); -     - //Call the data of the secondary table -         if(isset($data[' MoreInfo ']) &&intval($data[' MoreInfo ']) = = 1) {//if the MoreInfo property is set in the PC tab: whether to invoke the schedule data -             $ids=Array(); in             //$return The primary table data that is returned -             foreach($return  as $v) {//logging information in the Main table: $v-Each record in the main table to                 if(isset($v[' ID ']) &&!Empty($v[' ID '])) { +                     $ids[] =$v[' ID '];//ids[] is an array of article IDs that are sorted in the main table -}Else { the                     Continue; *                 } $             }Panax Notoginseng             if(!Empty($ids)) { -                 $this->db->table_name =$this->db->table_name. ' _data ';//Secondary table name the                 $ids=implode(‘\‘,\‘‘,$ids);//concatenation of commas into a string +                 $r=$this->db->select ("' ID ' in ('$ids'), ' * ', ', ', ', ', ' id ');//querying data in a secondary table related to data in a primary table A                 if(!Empty($r)) { the                     foreach($r  as $k=$v) {//data in a secondary table + //$return: The data in the primary table is returned, and the ID field value in the primary table corresponds to the ID field value in the schedule, which means that the ID stored in the primary table is equal to the value of the ID stored in the schedule in an article -                         if(isset($return[$k]))$return[$k] =Array_merge($v,$return[$k]);//Data in the primary table is merged into the secondary table $                     } $                 } -             } -         } the         return $return; -}

Step two: Call in the template file:

{pc:content action= "Lists_all" num= "order=" id DESC "page="$page"} {Loop$data $r $val}                <a href= "{$val[url]} " > <DL class= "Wenzhangliebiao" > <dt>$val[Thumb]} " Width= "height=" alt= "The Make money of apple Company" ></dt> <dd> < h3>{$val[Title]} $val[description],220, ' ... ')} </p> <div><span>{Date(' Y year m D Day H:i:s ',$val[Inputtime])} </span> &nbsp;&nbsp;&nbsp;&nbsp;<span>{Date(' H:i ',$val[UpdateTime])} Updates </span></div> </dd> </DL> </a>            {/Loop} {/PC}

PHPCMS-V9---How do I get the full-site article content via the {PC} tab?

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.