[SOLVED] Editable blocks

Post Reply
ctuxboy
Posts: 15
Joined: Wed May 25, 2022 7:22 pm

[SOLVED] Editable blocks

Post by ctuxboy »

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

Code: Select all

<?=sectionleft()?>
to my theme.php and re-visit the website, it shows Empty content , so far so good.

Next step remove

Code: Select all

<?=sectionleft()?>
and adding this code:

Code: Select all

<?= $Wcms->block('sectionleft') ?>
When re-visit the website and login, there is no editable block :?

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;
	}
?>
Is there missing something in my code? Why area/block sectionleft not showing?
Last edited by ctuxboy on Thu May 26, 2022 11:48 pm, edited 1 time in total.
ctuxboy
Posts: 15
Joined: Wed May 25, 2022 7:22 pm

Re: Editable blocks

Post by ctuxboy »

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:

Code: Select all

...
"blocks": {
        "sectionleft": {
            "content": "my content"
         }
}
...
After save this file, added

Code: Select all

<?= $Wcms->block('sectionleft') ?>
In theme.php, and works well.

So i added more static blocks 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?
Post Reply