Public Member Functions | |
getSuggestData () | |
Protected Member Functions | |
_toHtml () | |
Protected Attributes | |
$_suggestData = null |
Definition at line 30 of file Autocomplete.php.
_toHtml | ( | ) | [protected] |
Override this method in descendants to produce html
Reimplemented from Mage_Core_Block_Abstract.
Definition at line 34 of file Autocomplete.php.
00035 { 00036 $html = ''; 00037 00038 if (!$this->_beforeToHtml()) { 00039 return $html; 00040 } 00041 00042 $suggestData = $this->getSuggestData(); 00043 if (!($count = count($suggestData))) { 00044 return $html; 00045 } 00046 00047 $count--; 00048 00049 $html = '<ul><li style="display:none"></li>'; 00050 foreach ($suggestData as $index => $item) { 00051 if ($index == 0) { 00052 $item['row_class'] .= ' first'; 00053 } 00054 00055 if ($index == $count) { 00056 $item['row_class'] .= ' last'; 00057 } 00058 00059 $html .= '<li title="'.$this->htmlEscape($item['title']).'" class="'.$item['row_class'].'">' 00060 . '<span class="amount">'.$item['num_of_results'].'</span>'.$this->htmlEscape($item['title']).'</li>'; 00061 } 00062 00063 $html.= '</ul>'; 00064 00065 return $html; 00066 }
getSuggestData | ( | ) |
Definition at line 68 of file Autocomplete.php.
00069 { 00070 if (!$this->_suggestData) { 00071 $collection = $this->helper('catalogSearch')->getSuggestCollection(); 00072 $query = $this->helper('catalogSearch')->getQueryText(); 00073 $counter = 0; 00074 $data = array(); 00075 foreach ($collection as $item) { 00076 $_data = array( 00077 'title' => $item->getQueryText(), 00078 'row_class' => (++$counter)%2?'odd':'even', 00079 'num_of_results' => $item->getNumResults() 00080 ); 00081 00082 if ($item->getQueryText() == $query) { 00083 array_unshift($data, $_data); 00084 } 00085 else { 00086 $data[] = $_data; 00087 } 00088 } 00089 $this->_suggestData = $data; 00090 } 00091 return $this->_suggestData; 00092 }
$_suggestData = null [protected] |
Definition at line 32 of file Autocomplete.php.