mdmsoft / yii2-admin

Auth manager for Yii2 (RBAC Manager)
GNU General Public License v3.0
1.16k stars 574 forks source link

Use yii2-admin with yii2-advanced-template #133

Open tamer-hassan opened 9 years ago

tamer-hassan commented 9 years ago

per this post: https://github.com/nenad-zivkovic/yii2-advanced-template/issues/11

yii2-admin works great with the standard advanced template but not the improved yii2-advanced-template. Could you please advise what is needed to get yii2-admin to play nicely with yii2-advanced-template ?

Thanks

mdmunir commented 9 years ago

What the different standart advanced template with that template? http://www.yiiframework.com/doc-2.0/guide-structure-modules.html http://www.yiiframework.com/doc-2.0/guide-security-authorization.html

tamer-hassan commented 9 years ago

OK I found the reason for the issue.. Bootstrap css files are not loaded. This is because of the following default configuration in _protected/common/config/main.php

    'components' => [
        'assetManager' => [
            'bundles' => [
                // we will use bootstrap css from our theme
//                'yii\bootstrap\BootstrapAsset' => [
//                    'css' => [], // do not use yii default one
//                ],
            ...
            ],
        ],
        ....

commenting those 3 lines out solves the issue, but messes up the theme on the rest of the pages.

How to load bootstrap css from the improved advanced template's theme in yii2-admin to play nicely together?

tamer-hassan commented 9 years ago

I found a workaround, but I'm sure there are better ways to get this done.

in: _protected/vendor/mdmsoft/yii2-admin/views/layouts/main.php

after:

        <?php $this->head() ?>

I added the following 2 lines:

        <?php list(, $url) = Yii::$app->assetManager->publish('@webroot/themes/cerulean'); ?>
        <?php $this->registerCssFile($url.'/css/bootstrap.min.css'); ?>

Can you suggest any better option?

tamer-hassan commented 9 years ago

I followed your suggestions in comments here: http://www.yiiframework.com/extension/yii2-admin/ about how to use the extension to restrict access to the authmanager to a certain user, but it doesn't work.

I tried with route /admin/* but didn't work so I added route /backend/admin/* (and for some reason it is crossed out), and assigned that to the authManager role, but still, nobody is restricted from accessing the module.

Edit: Same issue exists when using yii2-admin with the standard yii2 advanced template, regardless of whether enablePrettyUrl is true). I am unable to restrict any users from accessing the authmanager.

I made sure I deleted the Access Control Filter completely from config.

Do i have to keep an 'as access' section in config? I though ACF is only a simple substitute for RBAC?

Any ideas?

tamer-hassan commented 9 years ago

Found my answer here: https://github.com/mdmsoft/yii2-admin/issues/93#issuecomment-68359512 This should be in documentation (for restricting only access to this module).

tamer-hassan commented 9 years ago

after updating yii2-admin to latest version, I lost the changes to views/layouts/main.php which I described in comment above: https://github.com/mdmsoft/yii2-admin/issues/133#issuecomment-77578366

In the near future, could there be a config option for the extension that could be used to register the needed assets (in case of using themed templates)?

dadinugroho commented 9 years ago

@thassan, I see that your workaround is working okay. But, I am thinking that is there possibility to set that on the AdminAssets.php? I am curious that it may be possible just to list the css there but then I am very new to yii2 and have not much understanding on the concept yet.