コード例 #1
0
 public function autosuggestionAction()
 {
     if ($this->request->isAjax() == true) {
         $Suggestion = new \WH\Model\Solr();
         $searchkeyword = $this->request->get("search");
         $Suggestion->setParam('searchname', $searchkeyword);
         $Suggestion->setParam('bycity', $this->currentCity);
         $Suggestion->setAutoSuggest();
         try {
             $autosuggestresult = $Suggestion->getSuggestResults();
         } catch (Exception $e) {
             $autosuggestresult = array();
         }
         echo json_encode($autosuggestresult['suggestions']);
     }
     exit;
 }
コード例 #2
0
 public function autosuggestionAction()
 {
     if ($this->request->isAjax() == true) {
         $Suggestion = new \WH\Model\Solr();
         $searchkeyword = $this->request->get("search");
         $Suggestion->setParam('searchname', $searchkeyword);
         $Suggestion->setParam('bycity', $this->currentCity);
         $Suggestion->setAutoSuggest();
         try {
             $autosuggestresult = $Suggestion->getSuggestResults();
             foreach ($autosuggestresult['suggestions'] as $key => $autos) {
                 $autosuggestresult['suggestions'][$key] = str_replace("/", " ", stripslashes($autos));
             }
         } catch (Exception $e) {
             $autosuggestresult['suggestions'] = array();
         }
         echo json_encode($autosuggestresult['suggestions']);
     }
     exit;
 }