Emlog Modify pagination Style (paging function) method summary

Source: Internet
Author: User

Do not modify the kernel to achieve Emlog page page , the next page effect

1, first in the template you use the module.php file to add custom pagination function, the code is as follows:

  code is as follows copy code

<?php
//blog: Custom paging function
function my_page ($count, $perlogs, $page, $url, $anchor = ') {
  $pnums = @ceil ($count /$perlogs);
  $re = ';
  $urlHome = preg_replace ("|[?") &/][^./?&=]*page[=/-]| "," ", $url);
 if ($page > 1) {
  $i = $page-1;
  $re = "<a href=" ". $url. $i." " > Prev </a> ". $re;
 }
 if ($page < $pnums) {
  $i = $page + 1;
  $re. = "<a href=" ". $url. $i." " > next page </a> ";
 }
 return $re;
}

2, in the call page of the place (typically log_list.php) file add the following code:

The code is as follows Copy Code

<?php
$page _loglist = My_page ($lognum, $index _lognum, $page, $pageurl);
echo $page _loglist;
?>

3, if the Broken language page will also invoke the modified paging style, then add the following code to the t.php file:

The code is as follows Copy Code

<?php
$page _t = My_page ($twnum, Option::get (' Index_twnum '), $page, Blog_url. ' t/?page= ');
echo $page _t;
?>

Method Two, modify the Emlog paging function

Locate the paging function in the Base Function library function.base.php (located under the Emlog Root/include/lib folder), probably in function.base.php 220~ 250 lines (If your function.base.php is the original document).
Replace the paging function of the source program with the following code:

The code is as follows Copy Code

/**
* Paging function
*
* Total @param int $count entries
* @param int $perlogs The number of display bars per page
* @param int $page current page number
* @param string $url The address of the page number
*/
function pagination ($count, $perlogs, $page, $url, $anchor = ') {
$pnums = @ceil ($count/$perlogs);
$page = @min ($pnums, $page);
$PREPG = $page-1; Previous page
$NEXTPG = ($page = = $pnums 0: $page + 1); Next page
$urlHome = Preg_replace ("|[?") &/][^./?&=]*page[=/-]| "," ", $url);

#开始分页导航内容
$re = "";
if ($pnums <=1) return false; If only one page jumps out
if ($page!=1) $re. = "<a href=" $urlHome $anchor "> Home </a>";
if ($PREPG) $re. = "<a href=" $url $prepg$anchor "> front page </a>";
for ($i = $page-5; $i <= $page +5 && $i <= $pnums; $i + +) {
if ($i > 0) {
if ($i = = $page) {
$re. = "<span> $i </span>";
} elseif ($i = = 1) {
$re. = "<a href=" $urlHome $anchor "> $i </a>";
} else {
$re. = "<a href=" $url $i$anchor "> $i </a>";
}
}
}
if ($NEXTPG) $re. = "<a href=" $url $nextpg$anchor "> Back page </a>";
if ($page!= $pnums) $re. = "<a href=" $url $pnums$anchor "> Last </a>";

#下拉跳转列表, looping through all page numbers
$re. = "Jump to <select name= ' topage ' size= ' 1 '
Onchange= ' window.location= ' $url ' +this.value ' >n ';
for ($i =1; $i <= $pnums; $i + +) {
if ($i = = $page) $re. = "<option value= ' $i ' selected> $i </option>n";
else $re. = "<option value= ' $i ' > $i </option>n";
}
$re. = "</select> page, total $pnums page";
return $re;
}

And if you do not drop the jump in the switch, delete the following code on it:

  code is as follows copy code

#下拉跳转列表, Loops list all page numbers
    $re. = "Jump to <select name= ' topage ' size= ' 1 '
    onchange= ' window.location= "$url" +this.value ' >n ";
    for ($i =1 $i <= $pnums $i + +) {
        if ($i = = $page) $re. = "<option value= ' $i ' selected> $i </option>n";
        else $re. = "<option value= ' $i ' > $i </option>n";
   }
     $re. = </select> page, total $pnums page ";

Of course, if you want to display a total of several pages, delete the above code after the return $re, add the following code before:

The code is as follows Copy Code

$re. = "Total $pnums page";


If you do not drop the jump switch, delete the following code on it:


#下拉跳转列表, looping through all page numbers

The code is as follows Copy Code
$re. = "Jump to <select name= ' topage ' size= ' 1 ' onchange= ' window.location=" $url "+this.value ' >n";
for ($i =1; $i <= $pnums; $i + +) {
if ($i = = $page) $re. = "<option value= ' $i ' selected> $i </option>n";
else $re. = "<option value= ' $i ' > $i </option>n";
}
$re. = "page, total $pnums page";

Of course, if you want to share a few pages, this display. The last line deleted above is not deleted and needs to be modified as follows:

  code is as follows copy code

$re. = "A total of $ Pnums page ";

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.