forked from laysense/laysense.cn
Manage dynamic blocks and expand the editor library
This commit is contained in:
@@ -1,39 +1,14 @@
|
||||
<?php
|
||||
|
||||
use App\Content\BlockTemplates;
|
||||
use App\Content\View;
|
||||
|
||||
$e = View::escape(...);
|
||||
?>
|
||||
<details class="studio-layers">
|
||||
<summary>首屏与目录</summary>
|
||||
<button type="button" disabled data-hero-control="image">首屏图片</button>
|
||||
<button type="button" disabled data-hero-control="1">首屏按钮 1</button>
|
||||
<button type="button" disabled data-hero-control="2">首屏按钮 2</button>
|
||||
<button type="button" disabled data-hero-control="navigation">本页目录</button>
|
||||
</details>
|
||||
<details class="studio-layers">
|
||||
<summary>按锚点新建区块</summary>
|
||||
<form class="admin-form" method="post" action="/admin/page-blocks/<?= $e($slug) ?>">
|
||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||
<input type="hidden" name="operation" value="create">
|
||||
<label>锚点<input name="key" pattern="[a-z0-9]+(-[a-z0-9]+)*" maxlength="70" placeholder="overview" required></label>
|
||||
<label>模板<select name="preset">
|
||||
<?php foreach (BlockTemplates::GROUPS as [$category, $templates]): ?>
|
||||
<optgroup label="<?= $e($category) ?>">
|
||||
<?php foreach ($templates as $preset => [$label]): ?>
|
||||
<option value="<?= $e($preset) ?>"><?= $e($label) ?></option>
|
||||
<?php endforeach ?>
|
||||
</optgroup>
|
||||
<?php endforeach ?>
|
||||
</select></label>
|
||||
<button type="submit" class="button button-outline">新建</button>
|
||||
</form>
|
||||
</details>
|
||||
<details class="studio-layers" id="blocks">
|
||||
<summary>区块顺序</summary>
|
||||
<ul class="admin-list studio-blocks">
|
||||
<?php foreach ($page['sections'] as $index => $item): ?>
|
||||
<?php $fixedSlot = $item['style'] === 'hero-links'; ?>
|
||||
<li>
|
||||
<div><strong><?= $e($item['title']) ?></strong><small>#<?= $e($item['key']) ?></small></div>
|
||||
<div class="actions studio-block-actions">
|
||||
@@ -44,8 +19,8 @@ $e = View::escape(...);
|
||||
<input type="hidden" name="key" value="<?= $e($item['key']) ?>">
|
||||
<input type="hidden" name="page_version" value="<?= $e($page['version']) ?>">
|
||||
<input type="hidden" name="version" value="<?= $e($item['version']) ?>">
|
||||
<button class="button button-outline" name="operation" value="up" type="submit" <?= $index === 0 ? 'disabled' : '' ?>>上移</button>
|
||||
<button class="button button-outline" name="operation" value="down" type="submit" <?= $index === count($page['sections']) - 1 ? 'disabled' : '' ?>>下移</button>
|
||||
<button class="button button-outline" name="operation" value="up" type="submit" <?= $fixedSlot || $index === 0 || $page['sections'][$index - 1]['style'] === 'hero-links' ? 'disabled' : '' ?>>上移</button>
|
||||
<button class="button button-outline" name="operation" value="down" type="submit" <?= $fixedSlot || $index === count($page['sections']) - 1 ? 'disabled' : '' ?>>下移</button>
|
||||
<button class="button button-outline" name="operation" value="delete" type="submit" data-confirm="删除这个区块?">删除</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user