WonderCMS Documentation

Live Demo

Experience WonderCMS firsthand with our live demo. Explore the admin interface and test the features in a real environment.

Demo Information

Note: Any changes made in the demo will be automatically reset every 10 minutes. For persistent changes, consider installing WonderCMS locally or on your server.

Installation

Default Login: yoursite.com/loginURL

Step-by-Step Installation

  1. Download latest version from official site
  2. Upload files to web server
  3. Visit domain in browser
  4. System automatically creates:
    • database.js configuration
    • Admin password (displayed on home page)
    • Default pages and structure

Other install options

  1. Option 2: Clone from GitHub:
    git clone https://github.com/WonderCMS/wondercms.git
  2. Option 3: Get hosting with WonderCMS pre-installed
  3. Option 4: Docker image
  4. Option 5: Install with cPanel (and Softaculous) - video tutorial

System Requirements

Minimum PHP version: 7.4+

Mandatory Requirements

Changing Default Login URL

For enhanced security, it's recommended to change the default login URL of your WonderCMS website.

Steps to Change Login URL

  1. Login to your WonderCMS website
  2. Open the settings panel and select the Security tab
  3. Find the Login URL field
  4. Change it to your desired URL (e.g., my-secret-login)
  5. Bookmark your new login URL for future access

Why Change the Default Login URL?

Changing your default login URL provides several security benefits:

Important Notes:
  • The login URL is case-sensitive
  • After changing the login URL, the login link will be automatically removed from the footer
  • Make sure to bookmark your new login URL as it won't be visible on your website

Example Configuration

// Before
Default login URL: yoursite.com/loginURL

// After
New login URL: yoursite.com/my-secret-login
Tip: Choose a login URL that is:
  • Easy for you to remember
  • Difficult for others to guess
  • Not related to your website's content

Changing Default Password

For enhanced security, it's crucial to change the default password after your initial WonderCMS setup.

Steps to Change Password

  1. Login to your WonderCMS website
  2. Go to Settings → Security
  3. Enter your current password in the Old password field
  4. Enter your new password in the New password field
  5. Click Change password
  6. You will be automatically logged out
  7. Login again using your new password

Password Requirements

Important Notes:
  • Always use a strong, unique password
  • Store your password securely (consider using a password manager)
  • Changing your password will log you out of all sessions

Best Practices

Tip: If you forget your password, you can reset it by editing the database.js file directly on your server.

Included security features

Key Security Measures

Initial tricks and tips on what to do and not to do

Heads up! As you continue reading, it should be obvious that the "admin" user has a lot of power and freedom, and should be careful from installing random themes or giving anyone else access.

Do

  • DO change the default password and login URL immediately after setting up WonderCMS.
  • DO always backup before updating.
  • DO only install themes and plugins only from sources you trust.
  • DO create functions.php instead of editing index.php.

Don't

  • DO NOT edit index.php - important because the built in one click updater overwrites index.php. Any changes made to index.php WILL BE LOST after clicking "Update".
  • DO NOT paste random/malicious JavaScript code, since WonderCMS supports running JavaScript anywhere.
  • DO NOT install custom modules from sources you do not trust. This can lead to your website being hacked.
  • DO NOT upload random SVG files. WonderCMS supports uploading SVG's which could also contain JavaScript code. Don't get tricked into uploading malicious SVG's. If in doubt, avoid uploading any SVG file extension.

Core Wcms Class Reference

Heads up! The Wcms class is the backbone of WonderCMS, handling everything from database management to plugin integrations.

Class Structure

class Wcms {
    // Core constants
    public const DB_CONFIG = 'config';
    public const DB_PAGES_KEY = 'pages';
    
    // Public properties
    public $currentPage;
    public $loggedIn;
    public $installedPlugins = [];
    
    // Key methods
    public function init(): void { ... }
    public function render(): void { ... }
    public function getDb(): stdClass { ... }
}

Key Responsibilities

Database Management

Handles JSON storage in database.js with methods for CRUD operations

Authentication

Manages admin sessions and security through:

  • Password hashing
  • CSRF protection
  • Login attempt monitoring

Essential Methods

Method Parameters Description
get() string $key Retrieve data from database.json

Default database file

This section presents the default database.js file that is generated the first time you visit your new WonderCMS website.

{
  "config": {
    "siteTitle": "Website title",
    "siteLang": "en",
    "adminLang": "en",
    "theme": "sky",
    "defaultPage": "home",
    "login": "loginURL",
    "forceLogout": false,
    "forceHttps": false,
    "saveChangesPopup": false,
    "modalPersistence": false,
    "logoutToLoginScreen": true,
    "password": "HIDDEN",
    "lastLogins": {},
    "lastModulesSync": "2025\/03\/15",
    "customModules": {
      "themes": {},
      "plugins": {}
    },
    "menuItems": {
      "0": {
        "name": "Home",
        "slug": "home",
        "visibility": "show",
        "subpages": {}
      },
      "1": {
        "name": "How to",
        "slug": "how-to",
        "visibility": "show",
        "subpages": {}
      }
    }
  },
  "pages": {
    "404": {
      "created": "2025-03-15T11:01:24+00:00",
      "modified": "2025-03-15T11:01:24+00:00",
      "visibility": "show",
      "title": "404",
      "keywords": "404",
      "description": "404",
      "content": "<center><h1>404 - Page not found<\/h1><\/center>",
      "subpages": {}
    },
    "home": {
      "created": "2025-03-15T11:01:24+00:00",
      "modified": "2025-03-15T11:01:24+00:00",
      "visibility": "show",
      "title": "Home",
      "keywords": "Enter, page, keywords, for, search, engines",
      "description": "A page description is also good for search engines.",
      "content": "<h1>Welcome to your website<\/h1>\n\n<p>",
      "subpages": {}
    },
    "how-to": {
      "created": "2025-03-15T11:01:24+00:00",
      "modified": "2025-03-15T11:01:24+00:00",
      "visibility": "show",
      "title": "How to",
      "keywords": "Enter, keywords, for, this page",
      "description": "A page description is also good for search engines.",
      "content": "<h2>Easy editing<\/h2>\n<p>After logging in, click anywhere to edit and click outside to save.",
      "subpages": {}
    }
  },
  "blocks": {
    "subside": {
      "content": "<h2>About your website<\/h2>\n\n<br>\n<p>"
    },
    "header": {
      "content": "<nav>You can include this in your theme.php and edit it.<\/nav>"
    },
    "footer": {
      "content": "&copy;2025 Your website"
    }
  }
}
Pro tip

Yes, you can edit your database file directly. If you plan to do so, make sure to back it up regularly, as any small mistake can make your website temporarily unaccessible.

Search Functionality

WonderCMS includes built-in search capabilities that theme developers can implement. The search feature provides real-time filtering and highlighting of content across pages.

Implementation Requirements

To enable search in your theme, include this in your theme:

3. Highlight Styling (CSS)

<?= $Wcms->search() ?>
Note: The search automatically indexes all pages and blog posts.

Theme Tag Reference

Tag Description
<?= $Wcms->search() ?> Outputs search input and required JS/CSS for search to work.

functions.php Usage

If functions.php exists in your theme directory, it will be automatically included to theme.php.

<?php
function themeFunctions($Wcms) {
  $Wcms->addListener('settings', function($content) {
      return str_replace('</head>', '<style>.custom-css {}</style></head>', $content);
  });
}
themeFunctions($Wcms);

Customizing the 404 Page

WonderCMS allows you to easily customize your 404 error page to match your website's design and provide helpful information to visitors.

Steps to Edit the 404 Page

  1. Login to your WonderCMS admin panel
  2. Visit your 404 page by going to: yoursite.com/404
  3. Edit the content like any other page:
    • Click on the content to edit
    • Make your changes
    • Click outside the editable area to save

Best Practices for 404 Pages

Tip: Your 404 page should:
  • Explain that the page wasn't found
  • Provide ways to find the correct content
  • Include your main navigation
  • Maintain your brand identity
Important Notes:
  • You must be logged in to edit the 404 page
  • Changes are saved automatically
  • The 404 page uses the same theme as your website
  • Test your 404 page by visiting a non-existent URL

Hiding Pages from Menu/Navigation

WonderCMS allows you to hide pages from the main navigation while keeping them accessible through direct URLs.

Steps to Hide a Page

  1. Login to your WonderCMS admin panel
  2. Go to Settings → Menu
  3. Locate the page you want to hide
  4. Click the "eye" icon next to the page name:
    • Open eye (👁️) = Page is visible
    • Closed eye (👁️‍🗨️) = Page is hidden
  5. The change is saved automatically
Tip: You can use this feature to:
  • Create private pages accessible only by URL
  • Organize your menu structure
  • Temporarily hide pages during updates
  • Create landing pages not linked in navigation
Important Notes:
  • Hidden pages are still accessible via direct URL
  • Search engines can still index hidden pages - except the login page which returns a 404 response
  • Hidden pages are indicated in the admin panel

Managing Subpages

To hide subpages:

  1. Open settings and menu - page section in the menu editor
  2. Click the eye icon next to the subpage
  3. Subpages can be hidden independently of their parent page

Example Use Cases

Admin security settings

These security enhancements provide granular control over admin interactions and session management. Manage them in Settings → Security.

Location: All settings below are found in the Security tab of admin settings.

Available Security Features

Setting Default Description
forceLogout Disabled by default Forces all active sessions to logout after password changes
forceHttps Disabled by default Enforces HTTPS connections site-wide. WonderCMS automatically checks for SSL, this will force to always use HTTPS. If you don't have SSL and force HTTPS, this can break your website by creating incorrect redirects.
saveChangesPopup Disabled by default Shows confirmation dialog before saving edits
modalPersistence Disabled by default Remembers last open tab in admin modals
logoutToLoginScreen Enabled by default Redirects to login screen instead of last page after logout

Detailed Explanations

1. Force Logout (forceLogout)

When enabled: Logs out admin after password changes
When disabled: Allows admin to remain logged in
Recommended for high-security environments or suspected unauthorized access

2. Force HTTPS (forceHttps)

When enabled: Redirects all HTTP traffic to HTTPS
When disabled: Allows both HTTP and HTTPS connections

Requires valid SSL certificate to prevent browser warnings

3. Save Changes Confirmation (saveChangesPopup)

When enabled: Shows "Are you sure?" dialog before saving any content
When disabled: Saves edits immediately on click-outside

4. Modal Persistence (modalPersistence)

When enabled: Remembers last active tab in admin panels
When disabled: Resets to first tab on each modal open

5. Logout Redirect (logoutToLoginScreen)

When enabled: Returns to login screen after logout
When disabled: Returns to last visited page after logout
Disabling provides smoother workflow but may expose admin URLs in browser history

Best Practices

Backup website and restore

Backup

  1. Login to your website
  2. Open settings
  3. Open security
  4. Click backup
  5. Download backup

Restore

  1. Upload backup ZIP
  2. Extract to root directory
  3. Verify file permissions

Forgotten password

Password Reset Process

  1. Access server via SSH/FTP
  2. Edit database.js
  3. Find "password" field
  4. Replace with default hashed password:
    "password": "$2y$10$AOcr4G3BUFXMWzNwV4J6ZuZsZXGjT8LZKGVXAChCaXd4kyAKvkUr6",          
  5. Login with "admin123"

Creating Editable Static Blocks

WonderCMS allows you to create both dynamic and static editable content areas. This section explains how to create and manage these blocks.

Basic Usage

Dynamic Editable Areas

<?= $Wcms->page('content') ?>

Static Editable Blocks

<?= $Wcms->block('yourEditableBlockName') ?>

Creating Static Blocks with functions.php

To create a new static editable block:

  1. Create or edit functions.php in your theme folder
  2. Add the following code:
<?php
function newEditableArea() {
  global $Wcms;

  // Create block if it doesn't exist
  if (empty($Wcms->get('blocks','newEditableArea'))) {
      $Wcms->set('blocks','newEditableArea', 'content', 'Your content here.');
  }

  // Get block content
  $value = $Wcms->get('blocks','newEditableArea','content');

  // Set default content if empty
  if (empty($value)) {
      $value = 'Empty content';
  }

  // Return editable or static content
  return $Wcms->loggedIn 
      ? $Wcms->block('newEditableArea')
      : $value;
}
?>
  1. Add the block to your theme:
<?= newEditableArea() ?>
  1. Visit your website to initialize the block
  2. Replace the function call with the static block tag:
<?= $Wcms->block('newEditableArea') ?>

Using the Additional Contents Plugin

For easier management of multiple editable areas:

  1. Download and install the Additional Contents plugin
  2. Upload it to your plugins folder
  3. A green "+" button will appear when logged in
  4. Use the plugin interface to create and manage editable areas
Tip: Static blocks are visible across all pages, making them ideal for content like:
  • Sidebar content
  • Footer information
  • Global announcements
  • Contact information
Important Notes:
  • Block names are case-sensitive
  • Always initialize blocks through functions.php first
  • Remove initialization code after first use
  • Use meaningful names for your blocks

Custom Modules

Custom modules allow you to create, share, and install themes and plugins in WonderCMS. This section explains how to create and manage custom modules.

Creating Custom Modules

To create a custom module, you need to include specific files and structure your module correctly.

Theme Module Requirements

theme-folder/
├── theme.php        # Main template file
├── css/
│   └── style.css    # Theme styles
├── preview.jpg
└── wcms-modules.json # Theme metadata
wcms-modules.json Example (Theme)
{
  "version": 1,
  "themes": {
      "theme-name": {
          "name": "Theme Name",
          "repo": "https://github.com/yourUsername/theme-name/tree/master",
          "zip": "https://github.com/yourUsername/theme-name/archive/master.zip",
          "summary": "Theme description",
          "version": "1.0.0",
          "image": "https://raw.githubusercontent.com/yourUsername/theme-name/master/preview.jpg"
      }
  }
}

Plugin Module Requirements

plugin-name/
├── plugin-name.php
├── preview.jpg
└── wcms-modules.json
wcms-modules.json Example (Plugin)
{
  "version": 1,
  "plugins": {
      "plugin-name": {
          "name": "Plugin Name",
          "repo": "https://github.com/yourUsername/plugin-name/tree/master",
          "zip": "https://github.com/yourUsername/plugin-name/archive/master.zip",
          "summary": "Plugin description",
          "version": "1.0.0",
          "image": "https://raw.githubusercontent.com/yourUsername/plugin-name/master/preview.jpg"
      }
  }
}
Note: The version: 1 at the top of wcms-modules.json is required and should not be modified unless you know what you are doing. :)

Installing Custom Modules

  1. Login to your WonderCMS admin panel
  2. Go to Settings → Themes or Settings → Plugins
  3. Scroll to the "Custom Modules" section
  4. Paste the full URL to your wcms-modules.json file
  5. Click "Add"
  6. Your module will appear in the available themes/plugins list
  7. Click "Install" to activate the module

Updating Modules

To update a module:

  1. Make your changes to the module files
  2. Update the version number in wcms-modules.json
  3. Push changes to your repository
  4. Users will see an update notification:
    • Automatically after 24 hours
    • Or immediately when clicking "Check for updates"

Sharing Your Module

To share your module with others:

  1. Ensure your module follows all requirements
  2. Share the wcms-modules.json URL
  3. Optionally, submit a pull request to the official WonderCMS repository:
    • Themes: themes-list.json
    • Plugins: plugins-list.json
Important: When creating plugins, ensure the PHP file name matches the plugin folder name (e.g., plugin-name/plugin-name.php).

Hooks System

WonderCMS provides a powerful hooks system that allows you to modify CMS behavior without modifying core files. Hooks are event listeners that let you execute custom code at specific points in the application lifecycle.

Basic Hook Usage

// Register a hook
$Wcms->addListener('hook_name', function($args) {
  // Modify arguments or perform actions

  return $args;
});

Common Hook Examples

1. Adding Custom CSS

// Add custom CSS to all pages
$Wcms->addListener('css', function($args) {
  $customCSS = '<link rel="stylesheet" href="custom.css">';
  $args[0] .= $customCSS;
  return $args;
});

2. Adding Custom JavaScript

// Add custom JS to all pages
$Wcms->addListener('js', function($args) {
  $customJS = '<script src="custom.js"></script>';
  $args[0] .= $customJS;
  return $args;
});

3. Modifying Page Content

// Modify page content before rendering
$Wcms->addListener('page', function($args) {
  // $args[0] contains the content
  // $args[1] contains the context (e.g., 'content', 'title')
  
  if ($args[1] === 'content') {
      $args[0] = str_replace('foo', 'bar', $args[0]);
  }
  return $args;
});

4. Modifying Admin Settings Page

// Add custom content to settings page
$Wcms->addListener('settings', function($content) {
  return str_replace('</head>', 
      '<style>.custom-settings { color: red; }</style></head>', 
      $content);
});

Advanced Hook Examples

1. Before Saving Content

// Modify content before saving
$Wcms->addListener('before_save', function($content) {
  // Sanitize content before saving
  $content[0] = strip_tags($content[0], '<p><a><strong><em>');
  return $content;
});

2. After Page Rendering

// Modify HTML after page rendering
$Wcms->addListener('after_render', function($html) {
  // Add analytics script before closing body tag
  return str_replace('</body>', 
      '<script>/* Analytics code */</script></body>', 
      $html);
});

3. File Upload Handling

// Process uploaded files
$Wcms->addListener('file_upload', function($fileData) {
  // Validate file type and size
  if ($fileData['size'] > 5000000) { // 5MB limit
      throw new Exception('File size too large');
  }
  return $fileData;
});

Search Hook

The search hook allows you to modify or extend the search functionality in WonderCMS. This hook is triggered when the search action is performed.

Example: Custom Search Results Formatting

<?php
$Wcms->addListener('search', function($args) {
    // $args[0] contains the search results HTML
    $results = $args[0];
    
    // Add custom wrapper around search results
    $args[0] = '<div class="custom-search-results">' . $results . '</div>';
    
    return $args;
});
?>

Example: Highlight Search Terms

<?php
$Wcms->addListener('search', function($args) {
    $searchTerm = $_GET['search'] ?? '';
    
    if (!empty($searchTerm)) {
        $highlighted = '<span class="search-highlight">' . $searchTerm . '</span>';
        $args[0] = str_ireplace($searchTerm, $highlighted, $args[0]);
    }
    
    return $args;
});
?>

Available Hooks

Hook Description Arguments
css Add or modify CSS files string $styles
js Add or modify JavaScript string $scripts
page Modify page content string $content, string $context
settings Modify admin settings page string $content
menu Modify menu HTML output string $menuHtml
footer Modify footer content string $footerContent
before_save Before saving content array $content
after_render After page rendering string $html
file_upload During file upload array $fileData
login_success After successful login array $data (ip, timestamp, user_agent)
login_failed After failed login attempt array $data (ip, timestamp, user_agent)
search Modify search results string $results

Hook Execution Order

1. css
2. js 
3. before_save
4. after_render
5. file_upload
6. search
Tip: Hooks can be added in theme's functions.php or in custom plugins. Always return modified arguments to ensure proper hook chaining.

Themes Development

Theme Structure and Theme Tags

theme/
├── theme.php        # Main template file
├── css/
│   └── style.css    # Theme styles
├── wcms-modules.json # Theme metadata
└── functions.php    # Optional theme functions

Creating a Theme in 8 Steps

Creating custom themes in WonderCMS is straightforward and flexible. Follow these steps to create your own theme:

1. Basic Template Structure

<?php global $Wcms ?>
<!DOCTYPE html>
<html lang="<?= $Wcms->get('config', 'siteLang') ?>">
 <head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <title><?= $Wcms->get('config', 'siteTitle') ?> - <?= $Wcms->page('title') ?></title>

  <?= $Wcms->css() ?>
  <link rel="stylesheet" href="<?= $Wcms->asset('css/style.css') ?>">
</head>

2. Admin Settings and Alerts

<body>
<?= $Wcms->settings() ?>
<?= $Wcms->alerts() ?>

3. Navigation Menu

<nav>
    <a href="<?= $Wcms->url() ?>">
        <?= $Wcms->siteTitle() ?>
    </a>
    <?= $Wcms->menu() ?>
</nav>

4. Main Content Area

<main>
    <?= $Wcms->page('content') ?>
</main>

5. Static Blocks

<aside>
    <?= $Wcms->block('subside') ?>
</aside>

6. Footer Section

<footer>
    <?= $Wcms->footer() ?>
</footer>

7. JavaScript Includes

    <?= $Wcms->js() ?>
</body>
</html>

8. Theme Metadata (wcms-modules.json)

{
  "version": 1,
  "themes": {
          "name": "Theme Name",
          "repo": "https://github.com/yourUsername/theme-name/tree/master",
          "zip": "https://github.com/yourUsername/theme-name/archive/master.zip",
          "summary": "Theme description",
          "version": "1.0.0",
          "image": "https://raw.githubusercontent.com/yourUsername/theme-name/master/preview.jpg"
  }
}

Theme Tags Reference

Tag Description
<?= $Wcms->css() ?> Includes admin CSS and allows plugins to add CSS
<?= $Wcms->js() ?> Includes admin JavaScript and allows plugins to add JS
<?= $Wcms->get('config', 'siteTitle') ?> Returns website title, as set in admin settings
<?= $Wcms->get('getSiteLanguage') ?> Returns website language
<?= $Wcms->settings() ?> Displays admin settings panel
<?= $Wcms->alerts() ?> Displays system alerts and messages
<?= $Wcms->header() ?> Can be used to include your header, by default includes an empty navigation
<?= $Wcms->search() ?> Creates search bar, which can get content from all pages and blog posts
<?= $Wcms->menu() ?> Outputs the navigation menu
<?= $Wcms->page('content') ?> Displays the main page content
<?= $Wcms->page('description') ?> Displays the page description
<?= $Wcms->page('keywords') ?> Displays the page keywords
<?= $Wcms->page('title') ?> Displays page name
<?= this('url') ?> Returns URL of where WonderCMS is installed
<?= $Wcms->block('subside') ?> Displays a static content block
<?= $Wcms->footer() ?> Displays the footer content
<?= $Wcms->asset('path') ?> Returns URL to theme assets

Best Practices

Tip: You can extend your theme's functionality by adding a functions.php file. This file is automatically loaded if present in your theme folder.

Server Configurations

.htaccess (Apache) - included by default

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?page=\$1 [L,QSA]
</IfModule>

Nginx Configuration

server {
    listen 80;
    server_name example.com;
    root /var/www/html;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    }
}

Caddy Server Configuration

example.com {
    root * /var/www/html
    php_fastcgi unix//var/run/php/php-fpm.sock
    file_server
    rewrite {
        to {path} {path}/ /index.php?page={path}
    }
}

IIS Web.config

<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="WonderCMS Routing">
                    <match url="^(.*)$" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php?page={R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

Using PHP Built-in Server

For local development, you can use PHP's built-in web server to quickly run your WonderCMS installation.

Important: This setup is intended for local development only and is not officially supported by WonderCMS.

Setup Instructions

  1. Create a new file named router.php in your WonderCMS root directory
  2. Add the following code to router.php:
<?php
if(pathinfo($_SERVER["REQUEST_URI"], PATHINFO_EXTENSION)) {
    // Serve asset files directly
    return false;   
} else {
    // Handle WonderCMS routing
    $_GET['page'] = parse_url($_SERVER["REQUEST_URI"])['path'];
    include 'index.php';
}
?>
  1. Start the PHP built-in server:
php -S localhost:8090 router.php
  1. Access your site at http://localhost:8090

Logout Fix

For proper logout functionality:

  1. Open index.php
  2. Find the line containing logout&token=
  3. Replace it with logout?token=
Note: The logout fix needs to be reapplied after each WonderCMS update.

Advantages

Limitations

Credits: This tutorial was contributed by @jellehak

Accessing Database Data

WonderCMS provides easy access to your website's data through the $Wcms->get() function. This section explains how to retrieve various types of data.

Accessing Page Data

To retrieve data for a specific page:

<?php echo $Wcms->get('pages', 'PAGENAME')->PARAM; ?>

Available Page Parameters

Parameter Description Example
content Page content <?php echo $Wcms->get('pages', 'about')->content; ?>
title Page title <?php echo $Wcms->get('pages', 'about')->title; ?>
description Page description <?php echo $Wcms->get('pages', 'about')->description; ?>
keywords Page keywords <?php echo $Wcms->get('pages', 'about')->keywords; ?>
created Date of page creation <?php echo $Wcms->get('pages', 'about')->created; ?>
modified Date of page last modified <?php echo $Wcms->get('pages', 'about')->modified; ?>
visibility Status of page visibility (controlled and synced with menu items) <?php echo $Wcms->get('pages', 'about')->visibility; ?>

Accessing Current Page Data

To retrieve data for the current page:

<?php echo $Wcms->page('PARAM'); ?>

Examples

<?php echo $Wcms->page('content'); ?>    // Current page content
<?php echo $Wcms->page('title'); ?>      // Current page title
<?php echo $Wcms->page('description'); ?> // Current page description
<?php echo $Wcms->page('keywords'); ?>    // Current page keywords

Accessing Site Configuration

To retrieve site-wide configuration settings:

<?php echo $Wcms->get('config', 'PARAM'); ?>

Available Configuration Parameters

Parameter Description Example
siteTitle Site title <?php echo $Wcms->get('config', 'siteTitle'); ?>
siteDescription Site description <?php echo $Wcms->get('config', 'siteDescription'); ?>
siteKeywords Site keywords <?php echo $Wcms->get('config', 'siteKeywords'); ?>
siteLang Site language <?php echo $Wcms->get('config', 'siteLang'); ?>
theme Active theme <?php echo $Wcms->get('config', 'theme'); ?>
login Login URL <?php echo $Wcms->get('config', 'login'); ?>
forceHttps HTTPS enforcement <?php echo $Wcms->get('config', 'forceHttps'); ?>

Accessing Block Data

To retrieve data from static blocks:

<?php echo $Wcms->get('blocks', 'BLOCKNAME', 'content'); ?>

Example

<?php echo $Wcms->get('blocks', 'footer', 'content'); ?>

Accessing Menu Data

To retrieve menu items:

<?php echo $Wcms->get('menu', 'items'); ?>

Example

<?php 
    $menuItems = $Wcms->get('menu', 'items');
    foreach ($menuItems as $item) {
        echo $item->name . ' - ' . $item->slug . '<br>';
    }
?>

Accessing Plugin Data

To retrieve plugin-specific data:

<?php echo $Wcms->get('plugins', 'PLUGINNAME', 'PARAM'); ?>

Example

<?php echo $Wcms->get('plugins', 'blog', 'posts'); ?>

Accessing All Data

To retrieve the entire database:

<?php echo print_r($Wcms->get('database'), true); ?>
Tip: Use print_r() or var_dump() to inspect the structure of the data returned by the $Wcms->get() function.
Important Notes:
  • Always sanitize and validate data before displaying it
  • Use proper escaping for HTML output
  • Be cautious when accessing sensitive data
  • Consider caching frequently accessed data

Conclusion

This guide has covered the essential aspects of working with WonderCMS, including:

Remember: WonderCMS is designed to be simple yet powerful. With these tools and techniques, you can create a wide range of websites and applications.

Additional Resources

Happy Coding! If you have any questions or need further assistance, feel free to reach out to the WonderCMS community.

Setting Data in the Database

WonderCMS provides the $Wcms->set() function to modify and save data in the database. This section explains how to use this function effectively.

Basic Syntax

<?php 
$Wcms->set('CATEGORY', 'ITEM', 'PARAM', 'VALUE');

Common Configuration Examples

Setting Website Title

<?php 
$Wcms->set('config', 'siteTitle', 'My website title');

Changing Theme

<?php 
$Wcms->set('config', 'theme', 'default');

Page Data Examples

Setting Page Title

<?php 
$Wcms->set('pages', 'Page-name', 'title', 'Your title here');

Setting Page Content

<?php 
$Wcms->set('pages', 'Page-name', 'content', 'Page content here');

Parameter Breakdown

Parameter Description Example Values
CATEGORY Main data category config, pages, blocks
ITEM Specific item to modify siteTitle, Page-name, blockName
PARAM Specific parameter to set title, content, keywords
VALUE Value to set String or array of data
Tip: You can use $Wcms->set() in:
  • Theme's functions.php
  • Custom plugins
  • Custom admin interfaces
Important Notes:
  • Changes are saved immediately
  • Use proper data sanitization before saving
  • Be cautious when modifying core configuration
  • Always backup your database before making bulk changes

Advanced Usage

For more complex data structures, you can pass arrays as values:

<?php 
$Wcms->set('config', 'customData', [
    'key1' => 'value1',
    'key2' => 'value2',
    'nested' => [
        'subKey' => 'subValue'
    ]
]);

Common Errors and Solutions

This section covers common issues encountered when using WonderCMS and their solutions.

Login URL Returns 404

Symptoms: "Sorry, page not found" error when visiting login URL

Solution 1: Enable Hidden Files

Solution 2: Create .htaccess Manually

Options -Indexes
ServerSignature Off
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA,L]
RewriteRule database.js - [F]
RewriteRule cache.json - [F]

500 Internal Server Error

Solution: Set file permissions to 644 and folder permissions to 755

Persistent "New WonderCMS Update Available" Message

If you're seeing a persistent update message even when your WonderCMS is up-to-date, this section explains the possible causes and solutions.

How Update Checking Works

WonderCMS performs two checks to determine if an update is available:

  1. Reads the local version from index.php
  2. Fetches the latest version from GitHub

If these versions differ or the check fails, the update message appears.

Common Causes and Solutions

1. Missing cURL Certificate (Local Development)

Symptoms: Running WonderCMS locally without proper SSL certificates

Solution: Install a certificate on your local computer

2. Hosting Doesn't Meet Requirements

Symptoms: Hosting environment lacks required components

Solution: Verify your hosting meets WonderCMS requirements

Consider using our recommended hosting partner

3. cURL Not Installed

Symptoms: Hosting environment lacks cURL extension

Solution:

  1. Contact your hosting provider to install cURL
  2. If you have server access, install cURL yourself:
    • Ubuntu/Debian: sudo apt-get install php-curl
    • CentOS/RHEL: sudo yum install php-curl
Tip: You can manually check for updates by clicking the "Check for updates" button in the Settings panel.
Important: If you're certain your installation is up-to-date and the message persists, it might indicate a connection issue between your server and GitHub.

Malformed URLs on Windows IIS

Solution 1

Configure web.config for clean URLs

Solution 2

public static function url($location = null) {
return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://')
    . $_SERVER['HTTP_HOST']
    . str_replace($_SERVER['DOCUMENT_ROOT'], '', 
        str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME']))
    . "/{$location}";
}

Apache2 404 Errors on Ubuntu LAMP

Solution:

  1. Open /etc/apache2/apache2.conf
  2. Find your localhost directory configuration
  3. Change AllowOverride None to AllowOverride All
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

Other Common Errors

"Require once functions" Error

Solution: Set correct ownership of the directory where WonderCMS is installed to www-data

Need More Help?

If you encounter an error not listed here, please report it in our GitHub issues section.