Inline Editing with Multiple pages - adamjimenez/shiftlib GitHub Wiki
Inline editing can be used to manage subpages belonging to a catcher file.
This is an example of a front-end catcher template, let's call it pages.catcher.php
.
<?php
$page_data = $cms->get_page();
$content = $page_data['content'];
?>
<div class="container">
<div class="row">
<div class="col-4">
<div class="list-group">
<?php foreach ($page_data['pages'] as $page): ?>
<a href="/<?=$page['page_name']; ?>" class="list-group-item"><?=$page['name']; ?></a>
<?php endforeach; ?>
</div>
</div>
<div class="col-8">
<?php if ($page_data['page']): ?>
<div sl-name="logo" sl-type="upload">
<?=image($content['logo']); ?>
</div>
<h1>
<div sl-name="heading" sl-type="heading">
<?=$content['heading']; ?>
</div>
</h1>
<div sl-name="copy" sl-type="editor">
<?=$content['copy']; ?>
</div>
<?php else: ?>
<div>
Select a page from the menu
</div>
<?php endif; ?>
</div>
</div>
</div>
<?php
load_js('shiftlib');
$cms->load_page_editor($page_data);
?>
The page content is stored internally in the cms_pages
table and is accessed via $page_data = $cms->get_page();
.
We pass this data to the page editor via: $cms->load_page_editor($page_data);
The page editor will detect that we are working on a catcher file and will spawn buttons for creating and removing subpages. The editable fields themselves are defined using HTML attributes. These are the attributes: