select = $this->_db->select() ->from(array('sb' => $this->_getTableName()), array('*')) ->joinLeft( array('pg' => $this->_getTableName($this->_tableAlias . '2Page')), '`pg`.`idSideBlock` = `sb`.`id`', array() ) ->where('`sb`.`show` = "y"') ->where('`pg`.`idPage` = ' . $this->_idPage . ' OR `sb`.`pageType` = "all"') ->group('id'); $this->_prepareListOptions($options); return $this->select; } protected function _prepareList(&$list) { parent::_prepareList($list); foreach (array_keys($list) as $k) { if ('page' == $list[$k]['linkType']) { $list[$k]['linkUrl'] = Qs_SiteMap::find(array('id' => $list[$k]['linkPageId']), null, null, 'url'); } } return true; } public function setIdPage($id) { $this->_idPage = intval($id); return $this; } }