Edit shared headers and footers as page types
This commit is contained in:
+50
-30
@@ -2,6 +2,7 @@
|
||||
use App\Content\Buttons;
|
||||
use App\Content\CanvasStyle;
|
||||
use App\Content\Database;
|
||||
use App\Content\LayoutPage;
|
||||
use App\Content\SiteDesign;
|
||||
use App\Content\View;
|
||||
|
||||
@@ -12,17 +13,21 @@ $previewUrl = '/admin/pages/' . $slug . '/preview';
|
||||
?>
|
||||
<a class="back-link" href="/admin">返回页面</a>
|
||||
<header class="admin-heading">
|
||||
<div><h1><?= $e($title) ?></h1><p class="studio-page-meta"><code><?= $e($path) ?></code>
|
||||
<span class="dashboard-page-state" data-published="<?= $page['status'] === 'published' ? 'true' : 'false' ?>"><?= $page['status'] === 'draft' ? '草稿' : '已发布' ?></span></p></div>
|
||||
<div><h1><?= $e($title) ?></h1><p class="studio-page-meta">
|
||||
<?php if ($layout): ?><span class="dashboard-page-state"><?= $e(LayoutPage::TYPES[$layout['kind']]) ?></span>
|
||||
<?php else: ?><code><?= $e($path) ?></code><span class="dashboard-page-state" data-published="<?= $page['status'] === 'published' ? 'true' : 'false' ?>"><?= $page['status'] === 'draft' ? '草稿' : '已发布' ?></span><?php endif ?>
|
||||
</p></div>
|
||||
<div class="actions">
|
||||
<a class="button button-outline" href="#studio-page-settings">页面设置</a>
|
||||
<?php foreach (['header' => '编辑页头', 'footer' => '编辑页脚'] as $kind => $label): ?>
|
||||
<?php $default = $layoutDefaults[$kind . '_id'] ?? ''; $id = $page[$kind . '_id'] ?? $default; ?>
|
||||
<a class="button button-outline" data-page-layout-editor="<?= $kind ?>" data-default-id="<?= $e($default) ?>"
|
||||
href="/admin/design/<?= $kind ?>/<?= $id ? $e($id) : 'new?default=1' ?>" target="_blank" rel="noopener"><?= $label ?></a>
|
||||
<?php endforeach ?>
|
||||
<button type="button" class="button button-outline" data-open-page-templates hidden>整页模板</button>
|
||||
<?php if ($page['status'] === 'published'): ?><a class="button button-outline" href="<?= $e($path) ?>">公开页面</a><?php endif ?>
|
||||
<?php if (!$layout): ?>
|
||||
<?php foreach (['header' => '编辑页头', 'footer' => '编辑页脚'] as $kind => $label): ?>
|
||||
<?php $defaultId = $layoutDefaults[$kind . '_id'] ?? ''; $id = $page[$kind . '_id'] ?? $defaultId; ?>
|
||||
<a class="button button-outline" data-page-layout-editor="<?= $e($kind) ?>" data-default-id="<?= $e($defaultId) ?>"
|
||||
href="<?= $id ? '/admin/pages/' . $e(LayoutPage::slug($kind, $id)) : '/admin/new-page?type=' . $e($kind) ?>" target="_blank" rel="noopener"<?= !($page['visibility'][$kind] ?? true) ? ' hidden' : '' ?>><?= $e($label) ?></a>
|
||||
<?php endforeach ?>
|
||||
<button type="button" class="button button-outline" data-open-page-templates hidden>整页模板</button>
|
||||
<?php if ($page['status'] === 'published'): ?><a class="button button-outline" href="<?= $e($path) ?>">公开页面</a><?php endif ?>
|
||||
<?php endif ?>
|
||||
<a class="button button-outline" href="<?= $e($previewUrl) ?>" target="_blank" rel="noopener">打开预览</a>
|
||||
</div>
|
||||
</header>
|
||||
@@ -32,7 +37,7 @@ $previewUrl = '/admin/pages/' . $slug . '/preview';
|
||||
<h2 id="studio-library-title">页面编辑</h2>
|
||||
<?= View::fragment('studio-templates', [
|
||||
'layers' => View::fragment('studio-layers', compact('page', 'slug', 'token')),
|
||||
'anchorForm' => View::fragment('studio-anchor-form', compact('slug', 'token')),
|
||||
'layoutKind' => $page['layout_kind'], 'slug' => $slug, 'token' => $token,
|
||||
]) ?>
|
||||
</aside>
|
||||
<div class="studio-workspace">
|
||||
@@ -158,30 +163,45 @@ $previewUrl = '/admin/pages/' . $slug . '/preview';
|
||||
</div>
|
||||
</details>
|
||||
<label>页面名称<input name="name" value="<?= $e($page['name']) ?>" required maxlength="100"></label>
|
||||
<label>SEO 标题<input name="title" value="<?= $e($page['title']) ?>" required maxlength="160"></label>
|
||||
<label>SEO 描述<textarea name="description" rows="2" maxlength="300"><?= $e($page['description']) ?></textarea></label>
|
||||
<?php if ($layout): ?>
|
||||
<input type="hidden" name="title" value="<?= $e($page['title']) ?>">
|
||||
<label><input type="checkbox" name="make_default" value="1"<?= $layoutDefault ? ' checked' : '' ?>> 用作站点默认<?= $e(LayoutPage::TYPES[$layout['kind']]) ?></label>
|
||||
<?php else: ?>
|
||||
<label>SEO 标题<input name="title" value="<?= $e($page['title']) ?>" required maxlength="160"></label>
|
||||
<label>SEO 描述<textarea name="description" rows="2" maxlength="300"><?= $e($page['description']) ?></textarea></label>
|
||||
<?php endif ?>
|
||||
<fieldset class="admin-options form-grid">
|
||||
<legend>页面显示</legend>
|
||||
<?php foreach (['header' => '页头', 'hero' => '首屏', 'footer' => '页脚'] as $area => $label): ?>
|
||||
<?php $visible = $page['visibility'][$area] ?? true; ?>
|
||||
<label><?= $e($label) ?><select name="show_<?= $e($area) ?>">
|
||||
<option value="1" <?= $visible ? 'selected' : '' ?>>显示</option>
|
||||
<option value="0" <?= !$visible ? 'selected' : '' ?>>隐藏</option>
|
||||
</select></label>
|
||||
<?php endforeach ?>
|
||||
</fieldset>
|
||||
<fieldset class="admin-options form-grid"><legend>页头、页脚与配色</legend>
|
||||
<?php foreach (['header' => '页头方案', 'footer' => '页脚方案', 'palette' => '配色方案'] as $kind => $label): ?>
|
||||
<label><?= $e($label) ?><select name="<?= $e($kind) ?>_id">
|
||||
<option value=""><?= $kind === 'palette' ? '页面原有配色' : '站点默认' ?></option>
|
||||
<?php $heroVisible = $page['visibility']['hero'] ?? true; ?>
|
||||
<label>首屏<select name="show_hero"><option value="1"<?= $heroVisible ? ' selected' : '' ?>>显示</option>
|
||||
<option value="0"<?= !$heroVisible ? ' selected' : '' ?>>隐藏</option></select></label>
|
||||
<?php if (!$layout): ?>
|
||||
<?php foreach (['header' => '页头', 'footer' => '页脚'] as $kind => $label): ?>
|
||||
<?php $visible = $page['visibility'][$kind] ?? true; ?>
|
||||
<label><?= $e($label) ?><select name="<?= $e($kind) ?>_choice">
|
||||
<option value="hidden"<?= !$visible ? ' selected' : '' ?>>隐藏</option>
|
||||
<option value=""<?= $visible && $page[$kind . '_id'] === null ? ' selected' : '' ?>>站点默认</option>
|
||||
<?php foreach ($designs as $item): ?>
|
||||
<?php if ($item['kind'] !== $kind) continue; ?>
|
||||
<option value="<?= $e($item['id']) ?>"<?= $visible && $page[$kind . '_id'] === $item['id'] ? ' selected' : '' ?>><?= $e($item['name']) ?></option>
|
||||
<?php endforeach ?>
|
||||
</select></label>
|
||||
<?php endforeach ?>
|
||||
<label>配色方案<select name="palette_id">
|
||||
<option value="">页面原有配色</option>
|
||||
<?php foreach ($designs as $item): ?>
|
||||
<?php if ($item['kind'] !== $kind) continue; ?>
|
||||
<option value="<?= $e($item['id']) ?>" <?= ($page[$kind . '_id'] ?? null) === $item['id'] ? 'selected' : '' ?>><?= $e($item['name']) ?></option>
|
||||
<?php if ($item['kind'] !== 'palette') continue; ?>
|
||||
<option value="<?= $e($item['id']) ?>"<?= $page['palette_id'] === $item['id'] ? ' selected' : '' ?>><?= $e($item['name']) ?></option>
|
||||
<?php endforeach ?>
|
||||
</select></label>
|
||||
<?php endforeach ?>
|
||||
<a href="/admin/design" target="_blank" rel="noopener noreferrer">管理设计配置</a>
|
||||
<?php endif ?>
|
||||
</fieldset>
|
||||
<?php if (($layout['kind'] ?? '') === 'header'): ?>
|
||||
<details class="admin-options" data-shared-auth<?= $layoutHasMember ? '' : ' hidden' ?>>
|
||||
<summary>会员登录设置</summary>
|
||||
<?= View::fragment('design-provider-fields', ['item' => $layout, 'provider' => $layout['payload']['provider'], 'layoutHasMember' => $layoutHasMember]) ?>
|
||||
</details>
|
||||
<?php endif ?>
|
||||
<textarea name="hero_actions" hidden><?= $e(Database::json(Buttons::validate($page['actions']))) ?></textarea>
|
||||
<?php
|
||||
$contentFields = [
|
||||
@@ -197,11 +217,11 @@ $previewUrl = '/admin/pages/' . $slug . '/preview';
|
||||
<input type="hidden" name="<?= $e($field) ?>" value="<?= $e($value) ?>">
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
<?php if ($slug !== 'home'): ?>
|
||||
<?php if (!$layout && $slug !== 'home'): ?>
|
||||
<label>发布状态<select name="status"><option value="draft" <?= $page['status'] === 'draft' ? 'selected' : '' ?>>草稿</option>
|
||||
<option value="published" <?= $page['status'] === 'published' ? 'selected' : '' ?>>已发布</option></select></label>
|
||||
<?php endif ?>
|
||||
<div class="form-submit"><button class="button button-primary" type="submit">保存页面</button></div>
|
||||
</form>
|
||||
</div>
|
||||
<?= View::fragment('studio-page-templates', compact('token')) ?>
|
||||
<?php if (!$layout): ?><?= View::fragment('studio-page-templates', compact('token')) ?><?php endif ?>
|
||||
|
||||
Reference in New Issue
Block a user