V9 recommended bit sorting problem solving method

Source: Internet
Author: User

Original website: http://bbs.phpcms.cn/thread-879943-1-1.html

Introduction: When using PHPCMS to do the site, some places to use the recommended list, such as slides, special recommendations and so on. Sometimes because of the importance of the article, I hope the article can be sorted according to the order number set in the background. But, Phpcms, it doesn't.
When using Phpcms to do the site, some places to use the recommended list, such as slides, special recommendations and so on. Sometimes, because of the importance of the article, I want the article to be sorted by the sort number set in the background. The code should then be:

{pc:content action= "position" posid= "1" order= "Listorder DESC" num= "3"}     $data $r }          html code    {/loop}{/PC}

where order= "Listorder DESC" is the meaning of sorting by hand. However, it will be found that order= "Listorder desc" effect and order= "id desc", in fact, there is no sort descending function, only the ID descending or the ID ascending.
Open the database to view the V9_position_data table, and you will find that the Listorder field in the table is the same as the ID.
Finally, we found a solution.
1. Open File:/phpcms/modules/admin/classes/push_api.class.php
Found it:

$info $info $d [' ID '];

This is the sentence, when adding an article or modify the article, the listorder becomes the same as the ID, so that the Listorder sort does not work.
So the above code should read:

$info $d [' ID '];

When you add an article or modify an article, you don't change the value of Listorder. But this alone is not possible, because the recommended tag in the data, is based on the V9_position_data table Listorder to sort, but the background update article sort, and did not update v9_position_data this table Listorder, So we have to add this function.
2. Open File:/phpcms/modules/content/content.php
Found it:

foreach ($_postas$id$listorder) {      $this->db->update ( Array (' Listorder ' +$listorder),array(' id ' =$id));}

Add it to the back (note that you add the code behind it, and do not modify the code above)

//Change the recommended bit sort start   $this->db_config = pc_base::load_config (' database '); $tablepre=$this->db_config[' Default ' [' Tablepre ']; $this->db->table_name =$tablepre." Position_data "; foreach($_post[' Listorders '] as $id=$listorder) {    $r=$this->db->get_one (Array(' id ' = =$id)); if($r[' Posid ']){      $this->db->update (Array(' Listorder ' =$listorder),Array(' id ' = =$id,modelid=>$modelid)); }   } //Change the recommended bit sort start

These two places can be used normally.

V9 recommended bit sorting problem solving method

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.