Authored by whb

搜索api配置

@@ -72,6 +72,12 @@ class Bootstrap extends Bootstrap_Abstract @@ -72,6 +72,12 @@ class Bootstrap extends Bootstrap_Abstract
72 $action = 'Index'; 72 $action = 'Index';
73 // 二级域名 73 // 二级域名
74 if (2 === $level) { 74 if (2 === $level) {
  75 + $url = strtolower($dispatcher->getRequest()->getRequestUri());
  76 + if(empty($url) || $url == '/index' || $url == '/') {
  77 + $urlAction = '/index';
  78 + } else {
  79 + $urlAction = $url;
  80 + }
75 $subDomain = strval($hostParts[0]); 81 $subDomain = strval($hostParts[0]);
76 switch (strtolower($subDomain)) { 82 switch (strtolower($subDomain)) {
77 case 'www': // 主站 83 case 'www': // 主站
@@ -80,17 +86,18 @@ class Bootstrap extends Bootstrap_Abstract @@ -80,17 +86,18 @@ class Bootstrap extends Bootstrap_Abstract
80 case 'web': 86 case 'web':
81 break; 87 break;
82 case 'search': // 搜索 88 case 'search': // 搜索
83 - $searchRequest = new Yaf\Request\Http('/product/search/index');  
84 - $dispatcher->setRequest($searchRequest); 89 + if($urlAction == '/index') {
  90 + $searchRequest = new Yaf\Request\Http('/product/search/index');
  91 + $dispatcher->setRequest($searchRequest);
  92 + }
85 break; 93 break;
86 case 'guang': // 逛 94 case 'guang': // 逛
87 $module = 'Guang'; 95 $module = 'Guang';
88 break; 96 break;
89 case 'list': // 商品列表 97 case 'list': // 商品列表
90 $module = 'Product'; 98 $module = 'Product';
91 - $url = strtolower($dispatcher->getRequest()->getRequestUri());  
92 //list列表的index 99 //list列表的index
93 - if(empty($url) || $url == '/index' || $url == '/') { 100 + if($urlAction == '/index') {
94 $listRequest = new Yaf\Request\Http('/product/list/index'); 101 $listRequest = new Yaf\Request\Http('/product/list/index');
95 $dispatcher->setRequest($listRequest); 102 $dispatcher->setRequest($listRequest);
96 } 103 }
@@ -18,3 +18,10 @@ routes.productgetProductPic.match = "/getProductPic" @@ -18,3 +18,10 @@ routes.productgetProductPic.match = "/getProductPic"
18 routes.productgetProductPic.route.module = Product 18 routes.productgetProductPic.route.module = Product
19 routes.productgetProductPic.route.controller = List 19 routes.productgetProductPic.route.controller = List
20 routes.productgetProductPic.route.action = getProductPic 20 routes.productgetProductPic.route.action = getProductPic
  21 +
  22 +;api(search api suggest)
  23 +routes.searchsuggest.type = "rewrite"
  24 +routes.searchsuggest.match = "/api/suggest"
  25 +routes.searchsuggest.route.module = Product
  26 +routes.searchsuggest.route.controller = Search
  27 +routes.searchsuggest.route.action = suggest