-
-
Notifications
You must be signed in to change notification settings - Fork 165
Create new editable areas or editable blocks
Robert Isoski edited this page Mar 30, 2020
·
5 revisions
- Blocks = static editable areas
- Regular editable areas = dynamic editable areas
<?= $Wcms->page('content')?>
<?= $Wcms->block('yourEditableBlockName')?>
- Download the additional contents plugin, unzip and upload to your plugins folder.
- A green "+" will appear once logged in, enabling you to create new editable areas easily and additionally hide/show them for each page.
- Create functions.php file in your theme folder.
- Paste the following code into functions.php - newEditableArea can be renamed to anything else.
<?php
function newEditableArea() {
global $Wcms;
// Check if the newEditableArea area is already exists, if not, create it
if (empty($Wcms->get('blocks','newEditableArea'))) {
$Wcms->set('blocks','newEditableArea', 'content', 'Your content here.');
}
// Fetch the value of the newEditableArea from database
$value = $Wcms->get('blocks','newEditableArea','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('newEditableArea');
}
// If not logged in, return block in non-editable mode
return $value;
}
?>
- Save functions.php and the changes made.
- Open theme.php and paste
<?=newEditableArea()?>
anywhere you wish to display this new editable area. - Visit your website.
- Once you've visited your website, the functions files will be called and your editable area is created.
- Remove
<?=newEditableArea()?>
from theme.php. - Final step:
<?= $Wcms->block('newEditableArea')?>
anywhere in your theme.php to display your newly created editable area.
<?=wCMS::page('content')?>
<?=wCMS::block('yourEditableBlockName')?>
- Download the additional contents plugin, unzip and upload to your plugins folder.
- A green "+" will appear once logged in, enabling you to create new editable areas easily and additionally hide/show them for each page.
- Create functions.php file in your theme folder.
- Paste the following code into functions.php - newEditableArea can be renamed to anything else.
<?php
function newEditableArea() {
// Check if the newEditableArea area is already exists, if not, create it
if (empty(wCMS::get('blocks','newEditableArea'))) {
wCMS::set('blocks','newEditableArea', 'content', 'Your content here.');
}
// Fetch the value of the newEditableArea from database
$value = wCMS::get('blocks','newEditableArea','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('newEditableArea');
}
// If not logged in, return block in non-editable mode
return $value;
}
?>
- Save functions.php and the changes made.
- Open theme.php and paste
<?=newEditableArea()?>
anywhere you wish to display this new editable area.
- You have now successfully created your first editable block called newEditableArea with the help of a function.
- Use
<?=wCMS::block('newEditableArea')?>
anywhere in your theme to display your static block. - You can remove the newEditableArea() function from functions.php since you don't need it any more and your editable block is already created.
Still need help?
- Ask a question or make a request in the community.
- Official website
Intro
- Home
- Demo
- Download
- One step install
- Requirements
- 5 file structure
- List of hooks
- Included libraries
- Create theme in 8 easy steps
- Create a plugin
- Custom modules
- Translations
- All security features described
Basic how to's
- Backup all files
- Change default login URL
- Change default password
- Create custom page template
- Create new editable areas or editable blocks
- Edit 404 page
- Get data from database
- Set data to database
- Hide page from menu
- Caddy web server config
- IIS server config
- NGINX server config
- Login
- Recover login URL
- Reset password
- Restore backup
- Update
- PHP built in server
Themes
- Create theme in 8 easy steps
- Add favicon
- Theme tags
- Update theme to work with WonderCMS 2.0.0
- Update theme to work with WonderCMS 3.0.0
- Share your themes with Custom modules
Plugins
- Quick intro on creating plugins and List of hooks
- Share your plugin with simply with Custom modules
Security
- All security features described
- Add SRI tags to your theme libraries
- Always redirect to https and www
- Additional security configuration(s)
- Add SRI tags to your theme libraries
- Better security mode (HTTPS and other features)
Features description
- One click update
- Optional: functions.php file
- Default database.js
- Allowed extensions file types for uploads
- Login URL doesn't work - 404
- 500 internal server error
- Persistent "New WonderCMS update available" message
- URLs mailformed on Windows IIS
- Other errors