How to add / create new editable areas

Post Reply
wiz
Site Admin
Posts: 195
Joined: Sat Oct 30, 2010 12:23 am

How to add / create new editable areas

Post by wiz » Sun Jan 01, 2017 11:41 pm

Below is an example of creating an editable area with the help of functions.php file.

Pasting the below inside your functions.php file, you're creating a new editable area named anotherEditableArea, which you also have include in your theme.php as shown at the end of this post.

Code: Select all

function anotherEditableArea() {
    // Check if the anotherEditableArea area is already exists, if not, create it.
    if (wCMS::getConfig('anotherEditableArea') === false) {
        wCMS::setConfig('anotherEditableArea', '<h4>Another subside!</h4><p>This is an example of another editable subside area.</p>');
    }

    // Fetch the value of anotherEditableArea from the database.
    $value = wCMS::getConfig('anotherEditableArea');
    // If value is empty, let's put something in it by default. (IMPORTANT)
    if (empty($value)) {
        $value = 'Empty content.';
    }
    // It's necessary to pass the editable method to the fetched value/content
    // to make the area editable ONLY if admin is logged in.
    if (wCMS::$loggedIn) {
        // If logged in, it must be editable
        return wCMS::editable('anotherEditableArea', $value);
    }
    // If not logged in, don't make it editable!
    return $value;
}
We're ready for the last step, adding the editable area into theme.php, like shown in the example below.

Code: Select all

<?=anotherEditableArea()?>
Once you have included the editable area in your theme.php, you will be able to edit it through your WonderCMS website.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest