$smarty->assign('pid', $id);
            $roles = $B->get_roles($id);
            $nroles = array();
            foreach ($roles as $role) {
                if ($role['pid'] != '' || $role['pid'] != null) {
                    $role['checked'] = ' checked="checked" ';
                }
                $nroles[] = $role;
            }
            $smarty->assign('roles', $nroles);
            $content = $smarty->fetch('pages/page_edit.tpl');
        } else {
            if ($_GET['action'] == 'addnewpage') {
                $roles = $B->get_roles();
                $smarty->assign('roles', $roles);
                $id = \DB::table(PREFIX . 'codo_pages')->max('id');
                $smarty->assign('pid', $id + 1);
                $content = $smarty->fetch('pages/page_edit.tpl');
            }
        }
    }
} else {
    $av_blocks = $B->get_all_blocks();
    //available block regions in a theme
    $B->save_blocks();
    $pages = $B->list_pages();
    $smarty->assign('av_blocks', $av_blocks);
    $smarty->assign('pages', $pages);
    $smarty->assign('theme', $B->theme);
    $content = $smarty->fetch('pages/pages.tpl');
}