private function prepareProperties() { $props = Property::getDb()->cache(function ($db) { return Property::find()->select('id, name, property_handler_id, key, property_group_id, has_static_values, is_eav, handler_additional_params')->all(); }, 86400, new TagDependency(['tags' => [ActiveRecordHelper::getCommonTag(Property::className())]])); foreach ($props as $one) { $additionalParams = Json::decode($one['handler_additional_params']); if (false === empty($additionalParams['use_in_file'])) { if (1 == $one['is_eav'] && false === isset(self::$ymlEavProperties[$one['id']])) { self::$ymlEavProperties[$one['id']] = ['name' => $one['name'], 'unit' => empty($additionalParams['unit']) ? '' : $additionalParams['unit'], 'key' => $one['key'], 'group_id' => $one['property_group_id'], 'handler_id' => $one['property_handler_id']]; } else { if (1 == $one['has_static_values'] && false === isset(self::$ymlStaticProperties[$one['id']])) { self::$ymlStaticProperties[$one['id']] = ['name' => $one['name'], 'unit' => empty($additionalParams['unit']) ? '' : $additionalParams['unit']]; } } } } }
/* * As you can see this is just a simple yii2 view file with several additional variables available * * For content rendering use $this->blocks! */ /** * @var \app\components\WebView $this * @var $breadcrumbs array * @var $model \app\modules\page\models\Page */ $this->params['breadcrumbs'] = $breadcrumbs; use yii\helpers\Html; // we need id of property that is related to todays-deals // in production it is better to fill it statically in your template for better performance $propertyId = \app\models\Property::getDb()->cache(function ($db) { return \app\models\Property::find()->where(['key' => 'todays_deals'])->select('id')->scalar($db); }, 86400, new \yii\caching\TagDependency(['tags' => [\devgroup\TagDependencyHelper\ActiveRecordHelper::getCommonTag(\app\models\Property::className())]])); ?> <div class="container rows-padding-top-bottom-20"> <div class="row"> <div class="col-md-12"> <h1 class="text-center"> <?php echo isset($this->blocks['h1']) ? $this->blocks['h1'] : Yii::t('app', 'Today\'s deals'); ?> </h1> <!-- here we use ProductsWidget to show the same products as in Today's deal prefiltered page --> <?php if (intval($propertyId) > 0) {