public static function unityItem($row) { if (!is_array($row)) { $id = $row; $item = Union::find($id); if (is_null($item)) { return ''; } $row = $item->getFields(); } $header = isset($row['header']) ? $row['header'] : $row['name']; // Заголовок $html[] = Html::tag('div', Html::tag('h3', $header), ['class' => 'header']); // подзаголовок if (ArrayHelper::keyExists('sub_header', $row)) { $html[] = Html::tag('p', $row['sub_header']); } // картинка с ссылкой $html[] = Html::tag('p', Html::a(Html::img($row['img'], ['width' => '100%', 'class' => 'thumbnail']), self::getUnionUrl($row))); // Описание $content = $row['description']; $content = self::getMiniText($content); $html[] = Html::tag('p', $content); return Html::tag('div', join('', $html), ['class' => 'col-lg-4 unityItem']); }
private function doAction($id, $callback) { $item = \app\models\Union::find($id); if (is_null($item)) { return self::jsonErrorId(101, 'Не найдено объединение'); } $callback($item); return self::jsonSuccess(); }
public function actionUnion_item($category, $id) { $item = Union::find($id); if (is_null($item)) { throw new Exception('Нет такого объединения'); } $categoryObject = UnionCategory::find(['id_string' => $category]); if (is_null($categoryObject)) { throw new Exception('Не найдена категория'); } return $this->render(['item' => $item, 'officeList' => $item->getOfficeList(['id', 'point_lat as lat', 'point_lng as lng', 'concat("<h5>",name,"</h5><div>",ifnull(content,""),"</div><p>",point_address,"</p>") as html']), 'breadcrumbs' => $categoryObject->getBreadCrumbs([$item->getField('name')]), 'category' => $categoryObject]); }
/** * Продукт * * @param $category string id_string * @param $union_id int идентификатор объединения * @param $id int идентификатор продукта gs_unions_shop_product.id * * @return string * @throws \cs\web\Exception */ public function actionProduct($category, $union_id, $id) { $item = Union::find($union_id); if (is_null($item)) { throw new Exception('Нет такого объединения'); } $categoryObject = UnionCategory::find(['id_string' => $category]); if (is_null($categoryObject)) { throw new Exception('Не найдена категория'); } $product = Product::find($id); if (is_null($product)) { throw new Exception('Не найден товар'); } $treeNode = TreeNode::find($product->getField('tree_node_id')); $breadcrumbs = $categoryObject->getBreadCrumbs(); $breadcrumbs = ArrayHelper::merge($breadcrumbs, [['url' => ['page/union_item', 'id' => $item->getId(), 'category' => $categoryObject->getField('id_string')], 'label' => $item->getName()], ['url' => ['union_shop/index', 'id' => $item->getId(), 'category' => $categoryObject->getField('id_string')], 'label' => 'Магазин'], ['url' => ['union_shop/category', 'id' => $item->getId(), 'category' => $categoryObject->getField('id_string'), 'shop_category' => $product->getField('tree_node_id')], 'label' => $treeNode->getField('name')], $product->getField('name')]); return $this->render(['union' => $item, 'shop' => $item->getShop(), 'breadcrumbs' => $breadcrumbs, 'category' => $categoryObject, 'treeNode' => $treeNode, 'product' => $product]); }