public function actionIndex($id, $page = 1) { $page = $page < 1 ? 1 : $page; $this->assign("subcategory", ForumSubcategory::findByPk($id)); $this->assign('threads', ForumThread::findAllForSubcategory($id, $page)); $this->assign('currentPage', $page); $this->assign('categories', ForumCategory::findAllBySection($this->sectionId, true)); }
public static function getAllForSelectTree($sectionId) { $categories = ForumCategory::findAllByAttributes(['section_id' => $sectionId]); $options = []; foreach ($categories as $cat) { $options[$cat->name] = []; foreach ($cat->subcategories as $sub) { $options[$cat->name][$sub->id] = $sub->title; } } return $options; }
<?php /* @var $this \mpf\modules\forum\controllers\Manage */ /* @var $model \mpf\modules\forum\models\ForumSubcategory */ echo \app\components\htmltools\Page::get()->title(\mpf\web\helpers\Html::get()->link($this->updateURLWithSection(['home', 'index']), $this->forumTitle) . " " . \mpf\modules\forum\components\Config::value('FORUM_PAGE_TITLE_SEPARATOR') . " New subcategory", [['url' => $this->updateURLWithSection(['manage', 'groups']), 'label' => 'Manage Groups'], ['url' => $this->updateURLWithSection(['manage', 'categories']), 'label' => 'Manage Categories'], ['url' => $this->updateURLWithSection(['manage', 'users']), 'label' => 'Manage Users'], ['url' => $this->updateURLWithSection(['manage', 'titles']), 'label' => 'Manage Titles'], ['url' => $this->updateURLWithSection(['manage', 'newCategory']), 'label' => 'New Category'], ['url' => $this->updateURLWithSection(['manage', 'newSubcategory']), 'label' => 'New Subcategory', 'htmlOptions' => $model->isNewRecord() ? ['class' => 'selected'] : []]]); echo \mpf\widgets\form\Form::get(['name' => 'save', 'model' => $model, 'theme' => 'default-wide', 'formHtmlOptions' => ['enctype' => 'multipart/form-data'], 'fields' => ['title', 'url_friendly_title', 'description', ['name' => 'category_id', 'type' => 'select', 'options' => \mpf\helpers\ArrayHelper::get()->transform(\mpf\modules\forum\models\ForumCategory::findAllBySection($this->sectionId), ['id' => 'name'])], ['name' => 'icon', 'type' => 'image', 'urlPrefix' => $this->getUploadUrl() . 'subcategories/']]])->display();
public function actionIndex() { $this->assign('categories', ForumCategory::findAllBySection($this->sectionId, true)); }
public function actionDelete() { if (isset($_POST['ForumUserGroup'])) { $models = ForumUserGroup::findAllByPk($_POST['ForumUserGroup']); foreach ($models as $model) { $model->delete(); } Messages::get()->success("Deleted!"); $this->goBack(); } if (isset($_POST['ForumCategory'])) { $models = ForumCategory::findAllByPk($_POST['ForumCategory']); foreach ($models as $model) { $model->delete(); } Messages::get()->success("Deleted!"); $this->goBack(); } if (isset($_POST['ForumSubcategory'])) { $models = ForumSubcategory::findAllByPk($_POST['ForumSubcategory']); foreach ($models as $model) { $model->delete(); } Messages::get()->success("Deleted!"); $this->goBack(); } }