Mage_CatalogSearch_Block_Autocomplete Class Reference

Inheritance diagram for Mage_CatalogSearch_Block_Autocomplete:

Mage_Core_Block_Abstract Varien_Object

List of all members.

Public Member Functions

 getSuggestData ()

Protected Member Functions

 _toHtml ()

Protected Attributes

 $_suggestData = null


Detailed Description

Autocomplete queries list

Definition at line 30 of file Autocomplete.php.


Member Function Documentation

_toHtml (  )  [protected]

Override this method in descendants to produce html

Returns:
string

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     }


Member Data Documentation

$_suggestData = null [protected]

Definition at line 32 of file Autocomplete.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:49 2009 for Magento by  doxygen 1.5.8