[SOLVED] How to add content blocks?
Posted: Thu Jan 28, 2021 3:25 am
Hello there, so I am new to WonderCMS, and am curious.. how do I add editable content blocks to pre-existing content?
small flat file CMS - simple website builder
https://www.wondercms.com/community/
By content blocks I'm reffering to making editable parts / sections of a static html website. Do I use a specific <div> to do this? And can only text be modified, or can images be as well?
Is there a way to make images editable? Like being able to move them around, replace, etc.wiz wrote: ↑Tue Feb 02, 2021 5:57 am Would something like this help?
https://github.com/robiso/wondercms/wik ... ble-blocks
It could be also used for loading existing editable areas, but they have to be already in the database.js file - preexisting for this to work.
Let us know if you need any help putting this together and please post any code examples so we can help you easier.
Code: Select all
<?= $Wcms->block('addition_content_1')?>
ty505 wrote: ↑Sun Feb 07, 2021 12:24 amIs there a way to make images editable? Like being able to move them around, replace, etc.wiz wrote: ↑Tue Feb 02, 2021 5:57 am Would something like this help?
https://github.com/robiso/wondercms/wik ... ble-blocks
It could be also used for loading existing editable areas, but they have to be already in the database.js file - preexisting for this to work.
Let us know if you need any help putting this together and please post any code examples so we can help you easier.
Code: Select all
<?php
$Wcms->get('blocks','addition_content_1','content')
?>
Code: Select all
<?php
function addition_content_1() {
global $Wcms;
// Check if the addition_content_1 area is already exists, if not, create it
if (empty($Wcms->get('blocks','addition_content_1'))) {
$Wcms->set('blocks','addition_content_1', 'content', 'Your content here.');
}
// Fetch the value of the addition_content_1 from database
$value = $Wcms->get('blocks','addition_content_1','content');
// If value is empty, let's put something in it by default
if (empty($value)) {
$value = 'Empty content';
}
if ($Wcms->loggedIn) {
// If logged in, return block in editable mode
return $Wcms->block('addition_content_1');
}
// If not logged in, return block in non-editable mode
return $value;
}
?>