本文整理汇总了PHP中Model_Category::getWidgets方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_Category::getWidgets方法的具体用法?PHP Model_Category::getWidgets怎么用?PHP Model_Category::getWidgets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model_Category
的用法示例。
在下文中一共展示了Model_Category::getWidgets方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_index
public function action_index()
{
$this->template->page_title = 'Главная страница';
//$this->template->block_center = array($block_center);
$category = new Model_Category('tree');
$categoryName = $this->request->param('category');
$categoryId = $category->getCategoryIdByUrl('glavnaya');
//ВИДЖЕТЫ ДЛЯ ГЛАВНОЙ СТРАНИЦЫ
$widgets = $category->getWidgets($categoryId);
$this->styles = array();
$wdgtarr = array();
// if($this->template->block_center!=NULL)
// {
// $oldWidgets = $this->template->block_center;
// foreach ($oldWidgets as $oldWidget)
// array_push($wdgtarr['block_center'], $oldWidget);
// }
$widgets = $this->getWidgets($categoryId);
if (is_array($widgets)) {
foreach ($widgets as $position => $widget) {
$this->template->{$position} = $widget;
}
}
$old_styles = $this->template->styles;
array_unique($this->styles);
$new_styles = array_merge($this->styles, $old_styles);
$this->template->styles = $new_styles;
}
示例2: getWidgets
public function getWidgets($categoryId, $page = '')
{
$category = new Model_Category('tree');
$widgets = $category->getWidgets($categoryId);
$wdgtarr = array();
$positions = $category->getWidgetPositions();
foreach ($positions as $position) {
if ($this->template->{$position}['position'] != NULL) {
$oldWidgets = $this->template->{$position}['position'];
foreach ($oldWidgets as $oldWidget) {
$wdgtarr[$position['position']][] = $oldWidget;
}
}
}
foreach ($widgets as $widget) {
//Виджеты
if ($widget['name'] == 'catalog' || $widget['name'] == 'catalog2') {
$page1 = $page;
} else {
$page1 = '';
}
if (is_file('css/' . $widget['name'] . '.less')) {
array_push($this->styles, 'css/' . $widget['name'] . '.less');
}
if (is_file('js/' . $widget['name'] . '.js')) {
array_push($this->template->scripts, 'js/' . $widget['name'] . '.js');
}
$action = Arr::get($widget, 'action', 'index');
$widget_url = 'widgets/' . $widget['name'] . '/' . $action . '/' . $widget['wid'] . $page1;
$wdgt = Request::factory($widget_url)->execute();
if (!isset($wdgtarr[$widget['position']])) {
$wdgtarr[$widget['position']] = array($wdgt);
} else {
array_push($wdgtarr[$widget['position']], $wdgt);
}
}
return $wdgtarr;
//Вывод в шаблон
}