如何将原生分页函数改写为支持长尾关键词的查询功能?

2026-04-03 06:091阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计352个文字,预计阅读时间需要2分钟。

如何将原生分页函数改写为支持长尾关键词的查询功能?

plaintextgistfile1.txt*** 分页函数* @param $nowPage int 当前页* @param $totalPage int 总页数* @param $url string 跳转的链接* 例:http://www.home.com/class/day2/code/page.php?xxx=xxxxxx=xxxpage**

如何将原生分页函数改写为支持长尾关键词的查询功能?

gistfile1.txt

/** * 分页函数 * @param $nowPage int 当前页 * @param $totalPage int 总页数 * @param $url string 跳转的连接,例:www.home.com/class/day2/code/page.php?xxx=xxx&xxx=xxx&page */ function pageHtml($nowPage, $totalPage, $url){ #构建左半边部分 //左半边需要的参数 $preOnePage = $nowPage-1;//当前页的上一页 $preTwoPage = $nowPage-2;//当前页的上上页 if( $nowPage==1 ){//当前页为左边界 $leftHtml = ""; }elseif( $preOnePage==1 ) {//当前页的上一页为左边界 $leftHtml = "

  • 上一页
  • "; $leftHtml .= "
  • $preOnePage
  • "; }elseif( $preTwoPage==1 ) {//当前页的上上页为左边界 $leftHtml = "
  • 上一页
  • "; $leftHtml .= "
  • $preTwoPage
  • "; $leftHtml .= "
  • $preOnePage
  • "; }else{//其他情况 $leftHtml = "
  • 上一页
  • "; $leftHtml .= "... "; $leftHtml .= "
  • $preTwoPage
  • "; $leftHtml .= "
  • $preOnePage
  • "; } #构建当前页部分 $nowHtml = "
  • $nowPage
  • "; #构建右半边的部分 //右半边需要的参数 $nextOnePage = $nowPage+1;//当前页的下一页 $nextTwoPage = $nowPage+2;//当前页的下下页 if( $nowPage==$totalPage ){//当前页为右边界 $rightHtml = ""; }elseif( $nextOnePage==$totalPage ) {//当前页的下一页为右边界 $rightHtml = "
  • $nextOnePage
  • "; $rightHtml .= "
  • 下一页
  • "; }elseif( $nextTwoPage==$totalPage ) {//当前页的下下页为右边界 $rightHtml = "
  • $nextOnePage
  • "; $rightHtml .= "
  • $nextTwoPage
  • "; $rightHtml .= "
  • 下一页
  • "; }else{//其他情况 $rightHtml = "
  • $nextOnePage
  • "; $rightHtml .= "
  • $nextTwoPage
  • "; $rightHtml .= "... "; $rightHtml .= "
  • 下一页
  • "; } //拼接分页HTML $pageHtml = $leftHtml . $nowHtml . $rightHtml; return $pageHtml; }

    本文共计352个文字,预计阅读时间需要2分钟。

    如何将原生分页函数改写为支持长尾关键词的查询功能?

    plaintextgistfile1.txt*** 分页函数* @param $nowPage int 当前页* @param $totalPage int 总页数* @param $url string 跳转的链接* 例:http://www.home.com/class/day2/code/page.php?xxx=xxxxxx=xxxpage**

    如何将原生分页函数改写为支持长尾关键词的查询功能?

    gistfile1.txt

    /** * 分页函数 * @param $nowPage int 当前页 * @param $totalPage int 总页数 * @param $url string 跳转的连接,例:www.home.com/class/day2/code/page.php?xxx=xxx&xxx=xxx&page */ function pageHtml($nowPage, $totalPage, $url){ #构建左半边部分 //左半边需要的参数 $preOnePage = $nowPage-1;//当前页的上一页 $preTwoPage = $nowPage-2;//当前页的上上页 if( $nowPage==1 ){//当前页为左边界 $leftHtml = ""; }elseif( $preOnePage==1 ) {//当前页的上一页为左边界 $leftHtml = "

  • 上一页
  • "; $leftHtml .= "
  • $preOnePage
  • "; }elseif( $preTwoPage==1 ) {//当前页的上上页为左边界 $leftHtml = "
  • 上一页
  • "; $leftHtml .= "
  • $preTwoPage
  • "; $leftHtml .= "
  • $preOnePage
  • "; }else{//其他情况 $leftHtml = "
  • 上一页
  • "; $leftHtml .= "... "; $leftHtml .= "
  • $preTwoPage
  • "; $leftHtml .= "
  • $preOnePage
  • "; } #构建当前页部分 $nowHtml = "
  • $nowPage
  • "; #构建右半边的部分 //右半边需要的参数 $nextOnePage = $nowPage+1;//当前页的下一页 $nextTwoPage = $nowPage+2;//当前页的下下页 if( $nowPage==$totalPage ){//当前页为右边界 $rightHtml = ""; }elseif( $nextOnePage==$totalPage ) {//当前页的下一页为右边界 $rightHtml = "
  • $nextOnePage
  • "; $rightHtml .= "
  • 下一页
  • "; }elseif( $nextTwoPage==$totalPage ) {//当前页的下下页为右边界 $rightHtml = "
  • $nextOnePage
  • "; $rightHtml .= "
  • $nextTwoPage
  • "; $rightHtml .= "
  • 下一页
  • "; }else{//其他情况 $rightHtml = "
  • $nextOnePage
  • "; $rightHtml .= "
  • $nextTwoPage
  • "; $rightHtml .= "... "; $rightHtml .= "
  • 下一页
  • "; } //拼接分页HTML $pageHtml = $leftHtml . $nowHtml . $rightHtml; return $pageHtml; }