public function indexAction() { $ns = new Zend_Session_Namespace(); $search = $this->getRequest()->getParam('q'); if (!empty($search)) { $this->view->search = htmlspecialchars($search); $this->view->results = Products::search($search, $ns->langid, false); } else { $this->_redirect('/'); } }
<?php $model = new Products(); $this->widget('zii.widgets.grid.CGridView', array('id' => 'products-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('title', 'price', array('class' => 'CButtonColumn', 'template' => '{view}{update}{delete}{images}', 'viewButtonUrl' => 'Yii::app()->createUrl("/shop/products/view", array("id" => $data->product_id))', 'updateButtonUrl' => 'Yii::app()->createUrl("/shop/products/update", array("id" => $data->product_id))', 'deleteButtonUrl' => 'Yii::app()->createUrl("/shop/products/delete", array("id" => $data->product_id))', 'buttons' => array('images' => array('label' => Yii::t('ShopModule.shop', 'images'), 'url' => 'Yii::app()->createUrl("/shop/image/admin", array("product_id" => $data->product_id))')))))); echo CHtml::link(Shop::t('Create a new Product'), array('products/create'));
public function actionExport() { $model = new Products(); $model->unsetAttributes(); // clear any default values if (isset($_POST['Products'])) { $model->attributes = $_POST['Products']; } $exportType = $_POST['fileType']; $this->widget('ext.heart.export.EHeartExport', array('title' => 'List of Products', 'dataProvider' => $model->search(), 'filter' => $model, 'grid_mode' => 'export', 'exportType' => $exportType, 'columns' => array('product_id', 'name', 'measure_id'))); }