Skip to content

Commit

Permalink
fixed page create from template with placeholders blocks closes #21
Browse files Browse the repository at this point in the history
  • Loading branch information
nadar committed Oct 15, 2018
1 parent baa57c7 commit d3fe858
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 15 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file. This projec

## 1.0.7.2 (in progress)

### Fixed

+ [#21](https://github.com/luyadev/luya-module-cms/issues/21) Fix issue when using templates with block placeholders.
+ [#147](https://github.com/luyadev/luya-module-cms/issues/147) Enable auto encoding for menu component, this dasllows the usage of html code for page titles, descriptions and seo titles.
+ [#145](https://github.com/luyadev/luya-module-cms/issues/145) Fixed issue where preloading of models wont have any effect for page properties.

Expand Down
19 changes: 10 additions & 9 deletions src/admin/views/page/drafts.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
<?php
use luya\cms\admin\Module;
?>
<div class="luya-content">
<h1><?php echo \luya\cms\admin\Module::t('draft_title'); ?></h1>
<p><?php echo \luya\cms\admin\Module::t('draft_text'); ?></p>
<h1><?php echo Module::t('draft_title'); ?></h1>
<p><?php echo Module::t('draft_text'); ?></p>
<div class="card" ng-controller="DraftsController">
<div class="card-content">
<table class="table">
<table class="table mb-0">
<thead>
<tr>
<th><?php echo \luya\cms\admin\Module::t('draft_column_id'); ?></th>
<th><?php echo \luya\cms\admin\Module::t('draft_column_title'); ?></th>
<th><?php echo \luya\cms\admin\Module::t('draft_column_action'); ?></th>
<th><?php echo Module::t('draft_column_title'); ?></th>
<th><?php echo Module::t('draft_column_action'); ?></th>
</tr>
</thead>
<tr ng-repeat="item in menuData.drafts">
<td>{{item.id}}</td>
<td>{{item.title}}</td>
<td><button type="button" ng-click="go(item.id)" class="btn btn-flat"><?php echo \luya\cms\admin\Module::t('draft_edit_button'); ?></button>
<td style="vertical-align: middle;"><a ng-click="go(item.id)">{{item.title}}</a></td>
<td><button type="button" ng-click="go(item.id)" class="btn btn-icon btn-sm btn-edit"><?= Module::t('draft_edit_button'); ?></button>
</tr>
</table>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/admin/views/page/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<a class="dropdown-item" ng-click="togglePageSettingsOverlay(2)" ng-if="propertiesData.length > 0">
<i class="material-icons">settings</i> <span><?= Module::t('view_update_properties_title'); ?></span>
</a>
<a class="dropdown-item" ng-click="togglePageSettingsOverlay(7)">
<a class="dropdown-item" ng-show="!isDraft" ng-click="togglePageSettingsOverlay(7)">
<i class="material-icons">timelapse</i> <span><?= Module::t('cmsadmin_settings_time_title'); ?></span>
</a>
<a class="dropdown-item" ng-click="togglePageSettingsOverlay(4)">
Expand Down
10 changes: 10 additions & 0 deletions src/models/Nav.php
Original file line number Diff line number Diff line change
Expand Up @@ -608,11 +608,21 @@ public function createPageFromDraft($parentNavId, $navContainerId, $langId, $tit

$navItemPage->save();

$idLink = [];
foreach ($pageBlocks as $block) {
$i = new NavItemPageBlockItem();
$i->attributes = $block->toArray();
$i->nav_item_page_id = $navItemPage->id;
$i->insert();
$idLink[$block->id] = $i->id;
}

// check if prev_id is used, check if id is in set - get new id and set new prev_ids in copied items
$newPageBlocks = NavItemPageBlockItem::findAll(['nav_item_page_id' => $navItemPage->id]);
foreach ($newPageBlocks as $block) {
if ($block->prev_id && isset($idLink[$block->prev_id])) {
$block->updateAttributes(['prev_id' => $idLink[$block->prev_id]]);
}
}

$navItem->nav_id = $nav->id;
Expand Down
7 changes: 2 additions & 5 deletions src/models/NavItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,12 +406,9 @@ public function copyPageItem($targetNavItem)
// check if prev_id is used, check if id is in set - get new id and set new prev_ids in copied items
$newPageBlocks = NavItemPageBlockItem::findAll(['nav_item_page_id' => $pageItem->id]);
foreach ($newPageBlocks as $block) {
if ($block->prev_id) {
if (isset($idLink[$block->prev_id])) {
$block->prev_id = $idLink[$block->prev_id];
}
if ($block->prev_id && isset($idLink[$block->prev_id])) {
$block->updateAttributes(['prev_id' => $idLink[$block->prev_id]]);
}
$block->update(false);
}

return true;
Expand Down

0 comments on commit d3fe858

Please sign in to comment.