How to restrict maximum number of pages in WebsiteBaker

by Boudewijn van den Akker - yze.nl
(orginal article written on wbhelp.nl)

Normally in WebsiteBaker you’re able to create an unlimited number of pages. But what if you want to restrict that to a certain number of pages, e.g. when your customer can only create a maximum of 5 pages.

Only 2 files needs to be changed:

Open /config.php and insert the following code right above the line “require once…”

define('MAX_PAGES','5');


(where 5 is the number of pages you can change to your needs)

Save the file.

Go to /admin/pages/index.php and open it

Scroll to the absolute bottom and insert the following code right above the line “// Parse template object”

if (defined('MAX_PAGES')) {
    if (intval(MAX_PAGES) <= $database->get_one( "SELECT count(*) from ".TABLE_PREFIX."pages")) {
        $template->set_var('DISPLAY_ADD', 'hide');
    }
}

Save the file

Now you can create a maximum of (in this example) 5 pages. When 5 pages are created the option to create another page is gone.

Happy baking!

This article is tagged with:
PHP Tricks Tutorials

Comments on this article


Due to large amounts of spam comments, the comments are disabled!