[SOLVED] Editable blocks
Posted: Wed May 25, 2022 8:30 pm
Hello,
I'm new with WonderCMS and try build my own theme.
Trying adding static blocks and follow this steps for wcms 3.0.0+
https://github.com/robiso/wondercms/wik ... ble-blocks
So adding a functions.php to my theme-folder.
After adding to my theme.php and re-visit the website, it shows Empty content , so far so good.
Next step remove and adding this code:
When re-visit the website and login, there is no editable block
Here is my functions.php:
Is there missing something in my code? Why area/block sectionleft not showing?
I'm new with WonderCMS and try build my own theme.
Trying adding static blocks and follow this steps for wcms 3.0.0+
https://github.com/robiso/wondercms/wik ... ble-blocks
So adding a functions.php to my theme-folder.
After adding
Code: Select all
<?=sectionleft()?>
Next step remove
Code: Select all
<?=sectionleft()?>
Code: Select all
<?= $Wcms->block('sectionleft') ?>
Here is my functions.php:
Code: Select all
<?php
function sectionleft() {
global $Wcms;
// Check if the sectionleft area is already exists, if not, create it
if (empty($Wcms->get('blocks','sectionleft'))) {
$Wcms->set('blocks','sectionleft', 'content', 'Your content here.');
}
// Fetch the value of the sectionleft from database
$value = $Wcms->get('blocks','sectionleft','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('sectionleft');
}
// If not logged in, return block in non-editable mode
return $value;
}
?>