Mecha CMS

Mecha CMS blog and documentation.

$manager and $config->page_type == 'manager'

Updated: Sunday, 07 August 2016

The difference between $manager and $config->page_type == 'manager' conditional statement.

$manager uses user role detection to determine whether the current user is logged in or not. While $config->page_type == 'manager' uses current page path detection to determine whether the current user is in the manager page or not, either he/she is logged in or not. Basically, $manager is equal to Guardian::happy() and $config->page_type == 'manager' is equal to $config->url_path == 'manager' || strpos($config->url_path, 'manager/') === 0.

Examples

Show Menu for Logged in Users Only

if($manager) {
    echo Menu::my_menu();
}

Show Menu Only in Manager Pages

if($config->page_type === 'manager') {
    echo Menu::my_menu();
}

Show Menu Only in Manager Pages, for Logged in Users Only

if($config->page_type === 'manager' && $manager) {
    echo Menu::my_menu();
}
Donation and Email Subscription