[SOLVED] How to add content blocks?

Ask for help or provide support to other members.
Post Reply
ty505
Posts: 4
Joined: Thu Jan 28, 2021 12:05 am

[SOLVED] How to add content blocks?

Post by ty505 »

Hello there, so I am new to WonderCMS, and am curious.. how do I add editable content blocks to pre-existing content?
User avatar
wiz
Admin
Posts: 569
Joined: Sat Oct 30, 2010 12:23 am

Re: How to add content blocks?

Post by wiz »

Hello ty, welcome to our WonderCMS community!

Could you explain in more detail what you mean? An example of what you need would be perfect :)
ty505
Posts: 4
Joined: Thu Jan 28, 2021 12:05 am

Re: How to add content blocks?

Post by ty505 »

wiz wrote: Fri Jan 29, 2021 9:51 am Hello ty, welcome to our WonderCMS community!

Could you explain in more detail what you mean? An example of what you need would be perfect :)
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?
User avatar
wiz
Admin
Posts: 569
Joined: Sat Oct 30, 2010 12:23 am

Re: How to add content blocks?

Post by wiz »

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.
ty505
Posts: 4
Joined: Thu Jan 28, 2021 12:05 am

Re: How to add content blocks?

Post by ty505 »

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.
Is there a way to make images editable? Like being able to move them around, replace, etc.
User avatar
wiz
Admin
Posts: 569
Joined: Sat Oct 30, 2010 12:23 am

Re: How to add content blocks?

Post by wiz »

There is a possibility of aligning images left, right and center. It also supports drag and drop for images, however the images cannot be free moved around yet (as in exact position), unless you're using CSS.

Hope this answers your questions, let me know if it doesn't. :)
mrguu
Posts: 1
Joined: Fri Feb 19, 2021 3:50 pm

Re: How to add content blocks?

Post by mrguu »

Hi,

I have a question to place the addition content variables like "addition_content_1" in my template file.

I can find the "addition_content_1" in my "database.js" file. But how can I place this variable now in my html template.

I try this, but doesn't work:

Code: Select all

<?= $Wcms->block('addition_content_1')?>
Do you have a tipp for me?

Thanks in advance
and thanks to the WonderCMS team for your great work so far.

---

ty505 wrote: Sun Feb 07, 2021 12:24 am
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.
Is there a way to make images editable? Like being able to move them around, replace, etc.
User avatar
wiz
Admin
Posts: 569
Joined: Sat Oct 30, 2010 12:23 am

Re: How to add content blocks?

Post by wiz »

Hi mrgu, welcome to WonderCMS.

What happens when if you try to use:

Code: Select all

<?php
	$Wcms->get('blocks','addition_content_1','content')
?>
OR

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;
	}
?>

Glad you're loving WonderCMS. Is there anything you feel is missing or you have had bad experience with?
Post Reply