[SOLVED] Additional editable areas on page

Post Reply
madhatter
Posts: 5
Joined: Tue Apr 11, 2017 11:14 am

[SOLVED] Additional editable areas on page

Post by madhatter »

First of all have to say I'm really liking this CMS - so simple, so small, so ideal!

I'm trying to create additional editable areas with the latest version of WonderCMS. I've had a read through viewtopic.php?f=20&t=588&p=1043&hilit=e ... reas#p1043 and I guess things have moved on since then as I don't see any C$ variables anymore in the code.

So I wanted to add another sidebar editable area and am trying to figure this out - thought I had it but not quite.

So I've added

Code: Select all

,
	'newbox' => [
	'content' => '<h3>Another editable box</h3>'
	]
to the index file underneath the blocks area.

I've then gone into my theme file and added

Code: Select all

<?=wCMS::block('newbox')?>
Obviously wrapped in a suitable div. Now the div (of course) shows fine but when logged in as admin unfortunately the editable box never shows on screen nor does the default content of that box show. What am I doing wrong?

Thanking you in advance!
User avatar
wiz
Admin
Posts: 569
Joined: Sat Oct 30, 2010 12:23 am

Re: Additional editable areas on page

Post by wiz »

Seems you've done everything correctly, but just in case here's what worked for me in a couple of steps
- opened database.js
- added a testBlock in the blocks section (pasting the whole blocks section below)

Code: Select all

    "blocks": {
        "footer": {
            "content": "&copy;2017 Your website"
        },
        "subside": {
            "content": "<h3>About your website<\/h3> <p>Your photo, website description, contact information, mini map or anything else.<\/p> <p>This content is static and visible on all pages.<\/p>"
        },
        "testBlock": {
            "content": "<h3>About your website<\/h3> <p>Your photo, website description, contact information, mini map or anything else.<\/p> <p>This content is static and visible on all pages.<\/p>"
        }
    }
- opened theme.php and added <?=wCMS::block('testBlock')?>
- it worked (even after editing and being logged out)

If you've done everything as described above, and I think you have, you may be experiencing this because your <?=wCMS::block('newbox')?> isn't wrapped in a <div> in your theme.php. If your block is wrapped in a <p> or a <span> in your theme PHP then this is the problem. Somebody reported something similar a couple of days ago on GitHub. If this isn't the issue, please paste your databse.js (only the blocks section) so we can see if anything is wrong.

Report back how your block is wrapped in your theme and we can work from there.
madhatter
Posts: 5
Joined: Tue Apr 11, 2017 11:14 am

Re: Additional editable areas on page

Post by madhatter »

Eureka!

Got it working - I needed to wrap an DIV with an ID (not class) around it, whereas the subside and content don't now.

Once I added a div with an ID around the code in the template it all started to work!

Thank you for your help - loving it!
User avatar
wiz
Admin
Posts: 569
Joined: Sat Oct 30, 2010 12:23 am

Re: Additional editable areas on page

Post by wiz »

You're most welcome and thank you for providing great details. Marking this as solved for now.

Can we do a re-test of this after we release 2.0.3 in the upcoming days? I think the default WonderCMS wrapping <span>'s cause all this. They will be changed to <div>'s in the next version along with a couple of other fixes.

Cheers!
madhatter
Posts: 5
Joined: Tue Apr 11, 2017 11:14 am

Re: [SOLVED] Additional editable areas on page

Post by madhatter »

Upgraded last week and all appears to be working fine.

However what I have noticed is that the editable area sits across all pages and editing it changes it across all pages. So it acts just like the subside rather then the main content block.

So at present it looks like you can't have a specific additional content block on a page. Is this correct?

Meanwhile I've tried remvoved the DIV and ID and it's working without it fine :) so looks like no need to add a div with ID anymore :)
User avatar
wiz
Admin
Posts: 569
Joined: Sat Oct 30, 2010 12:23 am

Re: [SOLVED] Additional editable areas on page

Post by wiz »

Thanks for the feedback madhatter.

Currently or by default, there is one additional content block which is static and shown on all pages. Did that answer your question? :)
Post Reply