Editable blocks issue
ctuxboy opened this issue ยท 5 comments
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/wiki/Create-new-editable-areas-or-editable-blocks
So adding a functions.php to my theme-folder.
After adding
<?=sectionleft()?>
to my theme.php and re-visit the website, it shows Empty content , so far so good.
Next step remove
<?=sectionleft()?>
and adding this code:
<?= $Wcms->block('sectionleft') ?>
When re-visit the website and login, there is no editable block.
Here is my functions.php:
<?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;
}
?>
Is there missing something in my code? Why area/block [b]sectionleft[/b] not showing?
My current php version is 7.4, try it also with php 7.0 and 8.0 without luck. Also tested with the default (Sky) theme, but also without luck.
Here you can see the phpinfo on my hosting-provider.
My test WonderCMS website is installed on a subdomain.
PS: I post this problem also in the community/forum, but there are no answers/help/tips yet.
Okay,
After a lot of research, i found it, how adding a new static block manually:
Open the database.js, and in the blocks-section, added the 'sectionleft' block:
...
"blocks": {
"sectionleft": {
"content": "my content"
}
}
...
After save this file, added
<?= $Wcms->block('sectionleft') ?>
In theme.php, and works well, now i have a editable area!
So i added more static blocks on this way, without using the functions.php!
I don't know this is a bug or maybe is needed update the docs about editable areas?
@ctuxboy thank you for reporting the original issue, we'll test the docs again and see if there's anything missing (and provide a fix).
@ctuxboy the issue has been identified and will be fixed with the next version of WonderCMS 3.3.3.
Thank you for your tests ๐
Reordering first item now published on latest WonderCMS 3.3.3 version.
Feel free to login to your WonderCMS website, open settings and "Check for updates".
The update should then show up. ๐