Rewrite the thinkphp u method so that it routes under paging normal _php instance

Source: Internet
Author: User

ThinkPHP3.1.3 when routing is enabled, its paging address is not the address of the route, because thinkphp3.2.1 code is not repaired, many people have encountered this problem, this article adopts the Olcms modification method to solve this problem, especially thanks to Phper Jack's contribution to this, the specific solution is to modify the thinkphp of the functions.php U method, around 287 lines:

 if (!empty ($vars)) { 
 ///Add parameter
 foreach ($vars as $var => $val) {
 if ('!== trim ($val))
 $url. = $depr. $var . $depr. UrlEncode ($val);
 

Add the following code later

* * TP Open Routing after the next page routing failure Problem page class URL assembly//If Open route if (C (' url_router_on ')) {foreach (C (' Url_route_rules ') as $zhaolg => $zlig) {//Traverse route if (strstr) ('/'.
      Group_name. $url, $zlig)) {//Find the routing rule from the URL $lg = strstr ($zhaolg, '/: '), and/or parse rule with parameters? 
        if ($LG) {//If the rule takes the parameter $tempzlg = Str_replace ('/: ', ', $LG);//Fetch parameter//dump ($TEMPZLG); if ($TEMPZLG) {if (C (' App_sub_domain_deploy ')) {$zlgurl = Str_replace ($zlig, $zhaolg, '/'. Group_name. $url);                
          The URL is replaced by the routing rule}else{$zlgurl = Str_replace ($zlig, $zhaolg, $url);//url Replace with routing rules}
          Note/s/:c/c/4/p/__page__//dump ($zlgurl); 
        $url = Str_replace ($lg. '/'. $tempzlg, ', $zlgurl);//url replacement Routing rule parameter}}else{//analysis rule takes no parameters if (C (' App_sub_domain_deploy ')) {$url = Str_replace ($zlig, $zhaolg, '/'. Group_name. $url);//url replaced by routing rule}else{= Str_replace ($zlig, $zhaolg,$url);//url replaced by Routing rules}}} 

This problem is resolved!

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.