Tipask question add popular Q & A module

Source: Internet
Author: User
Tags php file

A website is a Q & A system built with tipask. Today, the customer asked to add a hot question module. Previously, tipask's native modules were used, such as recommendation Q & A and unsolved Q &, it seems that I can only perform secondary development on my own. I found the secondary development about tipask on the Internet ...... So I simply flipped through the tipask code and added the popular question module in my way.

The main functions of tipask are all in the model folder. Find the system core file base. class. php, which has such a function fromcache, used to generate various modules under the function, such as reward questions, wonderful recommendations, etc, what we need to do is add a popular problem module based on the pre-and post-code.

For example, in the code

The code is as follows: Copy code

Case 'notelist': // The announcement list on the right of the homepage

Add our module code before:

The code is as follows: Copy code

Case 'hotlist': // hot question

$ This-> load ('Hot '); // www.111cn.net

$ Cachedata = $ _ ENV ['Hot ']-> get_list ();

Break;

Here I followed the recommend Recommendation module and created a new hot. class. php is used to call the above code. In fact, it can be used to call question. class. the list_by_condition function in the PHP file, but passed to question. class. the list_by_condition function in the PHP file can only be added to the SQL where judgment, while the popular module I need only needs to change order by, so I can only create a new hot. class. the PHP file is called by writing the database itself.

The hot. class. Php file is as follows:

The code is as follows: Copy code

Base = $ base;

$ This-> db = $ base-> db;

}

Function get_list ($ start = 0, $ limit = 7 ){

$ Hotlist = array ();

$ Query = $ this-> db-> query ("SELECT * FROM". DB_TABLEPRE. "question order by views desc limit $ start, $ limit"); // WWw.111Cn.net

While ($ hot = $ this-> db-> fetch_array ($ query )){

$ Hot ['Category _ name'] = $ this-> base-> category [$ hot ['CID'] ['name'];

$ Hot ['format _ time'] = tdate ($ hot ['Time']);

$ Hot ['Category _ name'] = $ this-> base-> category [$ hot ['CID'] ['name'];

$ Hot ['URL'] = url ('question/view/'. $ hot ['qid'], $ hot ['URL']);

$ Hot ['image'] = $ hot ['image']? $ Hot ['image']: 'css/default/recomend.jpg ';

$ Hotlist [] = $ hot;

}

Return $ hotlist;

}

}

?>

All right, tipask's secondary development of new modules is over. Just follow this example.

 

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.