$(function() { $("#sortable-content").sortable(); }); JS; $this->registerJs($script); */ $context = $this->context->id; $contextParams = ['sector' => $sector->id]; if ($enableUpdate) { echo '<div class="well">'; echo '<strong>Page Settings</strong><div class="pull-right">'; echo Html::a(Yii::t('app', $page->is_published ? 'Unpublish' : 'Publish'), array_merge(['/' . $context . '/toggle-publish-page', 'id' => $page->id], $contextParams), ['class' => 'btn btn-' . ($page->is_published ? 'danger' : 'success'), 'data' => ['method' => 'post']]); echo ' '; echo Html::a(Yii::t('app', 'Add Content Container'), ['/' . $context . '/create-container', 'id' => $page->id, 'sector' => $sector->id, 'caller' => $caller, 'type' => ContainerType::getIdByName(ContainerType::CONTENT_CONTAINER)], ['class' => 'btn btn-warning', 'data' => ['method' => 'post']]); echo ' '; echo Html::a(Yii::t('app', 'Add Static Container'), ['/' . $context . '/create-container', 'id' => $page->id, 'sector' => $sector->id, 'caller' => $caller, 'type' => ContainerType::getIdByName(ContainerType::STATIC_CONTAINER)], ['class' => 'btn btn-danger', 'data' => ['method' => 'post']]); echo '</div></div>'; } echo '<ul id="sortable-content">'; //Load page containers foreach ($page->containers as $container) { echo '<li class="sortable-container" id="container-' . $container->id . '">'; $is_published = $container->is_published; /** * Render Static Content * * staticConfig Param is required */ if ($container->type->name == ContainerType::STATIC_CONTAINER) { $caller = $container->staticContainer->name; if ($enableUpdate || $container->is_published) {
public function afterSave($insert, $changedAttributes) { $contentType = ContainerType::getIdByName(ContainerType::CONTENT_CONTAINER); //Create single container after insert if ($insert) { for ($i = 1; $i <= $this->containerCount; $i++) { $container = new Container(['page_id' => $this->id, 'position' => $i, 'is_published' => 0, 'type_id' => $contentType, 'attr' => ['data' => '<b>' . $this->title . ' Editable Content ' . '<b>']]); if (!$container->save()) { \yii\helpers\VarDumper::dump($container->errors); } } } $this->touch('updated_at'); return parent::afterSave($insert, $changedAttributes); }