From 829a67d41aacdf529455c0f315665c407ad5d35b Mon Sep 17 00:00:00 2001 From: Jason Woofenden Date: Fri, 1 Jan 2016 15:40:05 -0500 Subject: [PATCH] can choose page layouts, edit sidebar, etc --- admin_pages.html | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++--- admin_pages.php | 26 ++++++++++++++++++++--- admin_pages.sql | 2 ++ inc/cms.php | 13 +++++++++++- style.styl | 40 ++++++++++++++++++------------------ template.html | 14 +++++++------ 6 files changed, 122 insertions(+), 33 deletions(-) diff --git a/admin_pages.html b/admin_pages.html index e6630f5..72252ad 100644 --- a/admin_pages.html +++ b/admin_pages.html @@ -213,11 +213,11 @@ }); } }); - function make_wysiwyg(name) { + function make_wysiwyg(name, bodyid_postfix) { CKEDITOR.replace(name, { 'contentsCss': 'css.css?m=~css.css mtime~', 'allowedContent': true, - bodyId: '~$basename~' + '_wysiwyg_' + name, + bodyId: '~$basename~' + '_wysiwyg_' + (bodyid_postfix ? bodyid_postfix : name), 'stylesSet': [ { name: 'Paragraph', element: 'p'}, { name: 'Page Headline', element: 'h1'}, @@ -249,6 +249,43 @@ ] }); } + window.admin_pages_cur_layout = null + function admin_pages_layout(layout) { + if (layout === undefined) { + layout = document.getElementById('layout').value + } + if (typeof layout === 'string') { + layout = parseInt(layout); + } + console.log(layout); + if (layout === window.admin_pages_cur_layout) { + return; + } + // hide/show sidebar editor + if (layout === 0) { + document.getElementById('sidebar_editor').style.display = 'none' + } else { + document.getElementById('sidebar_editor').style.display = 'block' + } + // remove existing ckeditors + if (window.admin_pages_cur_layout !== null) { + for (name in CKEDITOR.instances) { + CKEDITOR.instances[name].destroy(); + } + } + // create ckeditors + if (layout === 0) { + make_wysiwyg('content', 'content_full_main'); + } else if (layout === 1) { + make_wysiwyg('content', 'content_with_sidebar_main'); + make_wysiwyg('sidebar_content', 'content_with_sidebar_sidebar_plain'); + } else { + make_wysiwyg('content', 'content_with_sidebar_main'); + make_wysiwyg('sidebar_content', 'content_with_sidebar_sidebar_bordered'); + } + + window.admin_pages_cur_layout = layout + } @@ -279,6 +316,9 @@
(If you'd like this page to appear in the navigation with a shorter title.)
+
Page Template/Layout
+
+
Page Contents
-
+
+ + + + - -
+ + + +
+