Dedecms independent model paging function is complete, dedecms independent model Paging

Source: Internet
Author: User

Dedecms independent model paging function is complete, dedecms independent model Paging

Dedecms actually has no architecture problems, but it is estimated that some of the functions are implemented by new users. There are many areas to be improved, such as the paging function, from the code, we can see that the person in charge was perfunctory at that time.

If two pages are displayed on the dede page, the total number of articles cannot be displayed. For example:

Under the normal Article model, the page of the list is as follows:

But in the independent model, this is the case.

At last, the information on a total of * pages * is missing. I believe that the first thing that comes to mind is where I used the error. Actually, it is not, the code in the dede independent model is reduced. The code for processing the list of independent models is in arc. sglistview. class. php. We can compare the code segments that are also responsible for displaying pages. What are the differences between the independent model and the common model:

Common article model:

/*** Get dynamic paging list ** @ access public * @ param string $ list_len list width * @ param string $ list_len list style * @ return string */function GetPageListDM ($ list_len, $ listitem = "index, end, pre, next, pageno") {global $ response _rewrite; $ prepage = $ nextpage = ''; $ prepagenum = $ this-> PageNo-1; $ nextpagenum = $ this-> PageNo + 1; if ($ list_len = ''| preg_match ("/[^ 0-9]/", $ list_len )) {$ list_len = 3 ;}$ totalpage = ceil ($ this-> Tota LResult/$ this-> PageSize); if ($ totalpage <= 1 & $ this-> TotalResult> 0) {return "<li> <span class = \" pageinfo \ "> 1 page /". $ this-> TotalResult. "records </span> </li> \ r \ n";} if ($ this-> TotalResult = 0) {return "<li> <span class = \" pageinfo \ "> 0 pages /". $ this-> TotalResult. "records </span> </li> \ r \ n ";} $ maininfo = "<li> <span class = \" pageinfo \ "> total <strong >{$ totalpage} </strong> pages <strong> ". $ this-> TotalResult. "</strong> entries </span> </Li> \ r \ n "; $ purl = $ this-> GetCurUrl (); // if it is enabled as static, then replace the rule if ($ pai_rewrite = 'y') {$ nowurls = preg_replace ("/\-/",". php? ", $ Purl); $ nowurls = explode ("? ", $ Nowurls); $ purl = $ nowurls [0];} $ geturl =" tid = ". $ this-> TypeID. "& TotalResult = ". $ this-> TotalResult. "&"; $ purl. = '? '. $ Geturl; $ optionlist = ''; // $ hidenform =" <input type = 'did' name = 'tid' value = '". $ this-> TypeID. "'> \ r \ n"; // $ hidenform. = "<input type = 'ddn' name = 'totalresult' value = '". $ this-> TotalResult. "'> \ r \ n"; // obtain the link of the previous and next pages if ($ this-> PageNo! = 1) {$ prepage. = "<li> <a href = '". $ purl. "PageNo = $ prepagenum '> previous page </a> </li> \ r \ n"; $ indexpage = "<li> <a href = '". $ purl. "PageNo = 1'> homepage </a> </li> \ r \ n ";} else {$ indexpage = "<li> <a> homepage </a> </li> \ r \ n";} if ($ this-> PageNo! = $ Totalpage & $ totalpage> 1) {$ nextpage. = "<li> <a href = '". $ purl. "PageNo = $ nextpagenum '> next page </a> </li> \ r \ n"; $ endpage = "<li> <a href = '". $ purl. "PageNo = $ totalpage '> last page </a> </li> \ r \ n ";} else {$ endpage = "<li> <a> last </a> </li> \ r \ n" ;}// obtain the numerical link $ listdd = ""; $ total_list = $ list_len * 2 + 1; if ($ this-> PageNo >=$ total_list) {$ j = $ this-> PageNo-$ list_len; $ total_list = $ this-> PageNo + $ list_len; if ($ total_list> $ totalpa Ge) {$ total_list = $ totalpage;} else {$ j = 1; if ($ total_list> $ totalpage) {$ total_list = $ totalpage;} for ($ j; $ j <= $ total_list; $ j ++) {if ($ j = $ this-> PageNo) {$ listdd. = "<li class = \" thisclass \ "> <a> $ j </a> </li> \ r \ n";} else {$ listdd. = "<li> <a href = '". $ purl. "PageNo = $ J'> ". $ j. "</a> </li> \ r \ n" ;}}$ plist = ''; if (preg_match ('/index/I', $ listitem )) $ plist. = $ indexpage; if (preg_match ('/pre/I', $ listitem)) $ Plist. = $ prepage; if (preg_match ('/pageno/I', $ listitem) $ plist. = $ listdd; if (preg_match ('/next/I', $ listitem) $ plist. = $ nextpage; if (preg_match ('/end/I', $ listitem) $ plist. = $ endpage; if (preg_match ('/option/I', $ listitem) $ plist. = $ optionlist; if (preg_match ('/info/I', $ listitem) $ plist. = $ maininfo; if ($ pai_rewrite = 'y') {$ plist = str_replace ('. php? Tid = ','-', $ plist); $ plist = str_replace (' & TotalResult = ','-', $ plist ); $ plist = preg_replace ("/& PageNo = (\ d +)/I", '-\ 1.html', $ plist);} return $ plist ;}
Independent Model:
/*** Get dynamic paging list ** @ access public * @ param int $ list_len list width * @ param string $ listitem list style * @ return string */function GetPageListDM ($ list_len, $ listitem = "index, end, pre, next, pageno") {global $ nativeplace, $ infotype, $ keyword; if (empty ($ nativeplace) $ nativeplace = 0; if (empty ($ infotype) $ infotype = 0; if (empty ($ keyword) $ keyword = ''; $ prepage = $ nextpage = ''; $ prepagenum = $ this-> PageNo-1; $ n Extpagenum = $ this-> PageNo + 1; if ($ list_len = "" | preg_match ("/[^ 0-9]/", $ list_len )) {$ list_len = 3 ;}$ totalpage = ceil ($ this-> TotalResult/$ this-> PageSize ); if ($ totalpage <= 1 & $ this-> TotalResult> 0) {return "<span class = \" pageinfo \ "> 1 page /". $ this-> TotalResult. "records </span>";} if ($ this-> TotalResult = 0) {return "<span class = \" pageinfo \ "> 0 pages /". $ this-> TotalResult. "record </span>" ;}$ purl = $ this-> Ge TCurUrl (); $ geturl = "tid = ". $ this-> TypeID. "& TotalResult = ". $ this-> TotalResult. "& nativeplace = $ nativeplace & infotype = $ infotype & keyword = ". urlencode ($ keyword ). "&"; $ hidenform = "<input type = 'did' name = 'tid' value = '". $ this-> TypeID. "'/> \ r \ n"; $ hidenform = "<input type = 'den den' name = 'nativeplace 'value =' $ nativeplace '/> \ r \ n "; $ hidenform = "<input type = 'den den 'name = 'infotype' value =' $ infotype'/> \ r \ n "; $ Hidenform = "<input type = 'den den 'name = 'keyword' value =' $ keyword'/> \ r \ n"; $ hidenform. = "<input type = 'ddn' name = 'totalresult' value = '". $ this-> TotalResult. "'/> \ r \ n"; $ purl. = "? ". $ Geturl; // get the link of the previous and next pages if ($ this-> PageNo! = 1) {$ prepage. = "<li> <a href = '". $ purl. "PageNo = $ prepagenum '> previous page </a> </li> \ r \ n"; $ indexpage = "<li> <a href = '". $ purl. "PageNo = 1'> homepage </a> </li> \ r \ n ";} else {$ indexpage = "<li> <a> homepage </a> </li> \ r \ n";} if ($ this-> PageNo! = $ Totalpage & $ totalpage> 1) {$ nextpage. = "<li> <a href = '". $ purl. "PageNo = $ nextpagenum '> next page </a> </li> \ r \ n"; $ endpage = "<li> <a href = '". $ purl. "PageNo = $ totalpage '> last page </a> </li> \ r \ n ";} else {$ endpage = "<li> <a> last </a> </li>" ;}// get a digital link $ listdd = ""; $ total_list = $ list_len * 2 + 1; if ($ this-> PageNo >=$ total_list) {$ j = $ this-> PageNo-$ list_len; $ total_list = $ this-> PageNo + $ list_len; if ($ total_list> $ totalpage) {$ total_list = $ totalpage;} else {$ j = 1; if ($ total_list> $ totalpage) {$ total_list = $ totalpage ;}}for ($ j; $ j <=$ total_list; $ j ++) {if ($ j = $ this-> PageNo) {$ listdd. = "<li class = \" thisclass \ "> <a> $ j </a> </li> \ r \ n";} else {$ listdd. = "<li> <a href = '". $ purl. "PageNo = $ J'> ". $ j. "</a> </li> \ r \ n" ;}}$ plist = $ indexpage. $ prepage. $ listdd. $ nextpage. $ endpage; return $ plist ;}

Observe carefully that the sentence $ maininfo = "<li> <span class = \" pageinfo \ "> total <strong >{$ totalpage} is added at around 28 rows in the normal model. </ strong> page <strong> ". $ this-> TotalResult. "</strong> entries </span> </li> \ r \ n", but not in the independent model.

In addition, the $ maininfo value is added to the general model at the end.$plistString. (In more details, the common model also determines whether the tag has the info attribute to determine whether to add it:

1 if(preg_match('/info/i', $listitem)) $plist .= $maininfo;

) In the independent model, all of these are saved.

It is very easy to modify the independent model. However, "the common model also determines whether the tag has the info attribute to decide whether to add it, here, we do not judge whether to add maininfo directly in any case:

/*** Get dynamic paging list ** @ access public * @ param int $ list_len list width * @ param string $ listitem list style * @ return string */function GetPageListDM ($ list_len, $ listitem = "index, end, pre, next, pageno") {global $ nativeplace, $ infotype, $ keyword; if (empty ($ nativeplace) $ nativeplace = 0; if (empty ($ infotype) $ infotype = 0; if (empty ($ keyword) $ keyword = ''; $ prepage = $ nextpage = ''; $ prepagenum = $ this-> PageNo-1; $ n Extpagenum = $ this-> PageNo + 1; if ($ list_len = "" | preg_match ("/[^ 0-9]/", $ list_len )) {$ list_len = 3 ;}$ totalpage = ceil ($ this-> TotalResult/$ this-> PageSize ); if ($ totalpage <= 1 & $ this-> TotalResult> 0) {return "<span class = \" pageinfo \ "> 1 page /". $ this-> TotalResult. "records </span>";} if ($ this-> TotalResult = 0) {return "<span class = \" pageinfo \ "> 0 pages /". $ this-> TotalResult. "records </span>" ;}$ maininfo = "<li> <Span class = \ "pageinfo \"> total <strong >{$ totalpage} </strong> pages <strong> ". $ this-> TotalResult. "</strong> entries </span> </li> \ r \ n"; $ purl = $ this-> GetCurUrl (); $ geturl = "tid = ". $ this-> TypeID. "& TotalResult = ". $ this-> TotalResult. "& nativeplace = $ nativeplace & infotype = $ infotype & keyword = ". urlencode ($ keyword ). "&"; $ hidenform = "<input type = 'did' name = 'tid' value = '". $ this-> TypeID. "'/> \ r \ n"; $ hidenform = "<input type = 'H Idden 'name = 'nativeplace' value = '$ nativeplace'/> \ r \ n "; $ hidenform = "<input type = 'den den 'name = 'infotype' value =' $ infotype'/> \ r \ n "; $ hidenform = "<input type = 'den den 'name = 'keyword' value =' $ keyword'/> \ r \ n"; $ hidenform. = "<input type = 'ddn' name = 'totalresult' value = '". $ this-> TotalResult. "'/> \ r \ n"; $ purl. = "? ". $ Geturl; // get the link of the previous and next pages if ($ this-> PageNo! = 1) {$ prepage. = "<li> <a href = '". $ purl. "PageNo = $ prepagenum '> previous page </a> </li> \ r \ n"; $ indexpage = "<li> <a href = '". $ purl. "PageNo = 1'> homepage </a> </li> \ r \ n ";} else {$ indexpage = "<li> <a> homepage </a> </li> \ r \ n";} if ($ this-> PageNo! = $ Totalpage & $ totalpage> 1) {$ nextpage. = "<li> <a href = '". $ purl. "PageNo = $ nextpagenum '> next page </a> </li> \ r \ n"; $ endpage = "<li> <a href = '". $ purl. "PageNo = $ totalpage '> last page </a> </li> \ r \ n ";} else {$ endpage = "<li> <a> last </a> </li>" ;}// get a digital link $ listdd = ""; $ total_list = $ list_len * 2 + 1; if ($ this-> PageNo >=$ total_list) {$ j = $ this-> PageNo-$ list_len; $ total_list = $ this-> PageNo + $ list_len; if ($ total_list> $ totalpage) {$ total_list = $ totalpage;} else {$ j = 1; if ($ total_list> $ totalpage) {$ total_list = $ totalpage ;}}for ($ j; $ j <=$ total_list; $ j ++) {if ($ j = $ this-> PageNo) {$ listdd. = "<li class = \" thisclass \ "> <a> $ j </a> </li> \ r \ n";} else {$ listdd. = "<li> <a href = '". $ purl. "PageNo = $ J'> ". $ j. "</a> </li> \ r \ n" ;}}$ plist = $ indexpage. $ prepage. $ listdd. $ nextpage. $ endpage; return $ plist ;}

This article is original. For more information, see the source:

1. csdn: http://blog.csdn.net/jianghejie123/article/details/40026693

2. My Website: http://jcodecraeer.com/a/phpjiaocheng/2014/1011/1741.html



How does dedecms implement the paging function of creating a new model?

You have to use {dede: pagebreak/} for pagination on the article page. You can add this to the page where you need to pagination. If you don't understand this, you can ask questions at any time.
 
How to Set pagination on dedecms custom model document page

Copy the article model and the content field will be paginated.

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.