maks757/yii2-honors

此组件允许用户处理成就。

安装: 24

依赖项: 0

建议者: 0

安全性: 0

星标: 0

关注者: 2

分支: 0

开放问题: 0

类型:yii2-extension

1.1.4 2016-11-03 17:47 UTC

This package is not auto-updated.

Last update: 2024-09-28 20:09:06 UTC


README

状态扩展开发

安装

composer.phar require maks757/yii2-honors

或者

composer require maks757/yii2-honors

应用迁移

php yii migrate --migrationPath=@vendor/maks757/yii2-honors/migrations

或者

yii migrate --migrationPath=@vendor/maks757/yii2-honors/migrations

配置

main.php (配置)
'modules' => [
    'honor' => [
        'class' => \bl\honors\HonorsModule::className()
    ],
],
'components' => [
    // Images config
    'imagableHonor' => [
        'class' => 'bl\imagable\Imagable',
        'imageClass' => \bl\honors\components\image\CreateImageImagine::className(),
        'nameClass' => \bl\honors\components\image\GenerateName::className(),
        'imagesPath' => '@frontend/web/honorImage',
        'categories' => [
            'category' => [
                'honor' => [
                    'origin' => false,
                    'size' => [
                        'long' => [
                            'width' => 500,
                            'height' => 500,
                        ],
                        'short' => [
                            'width' => 200,
                            'height' => 200,
                        ],
                    ]
                ],
            ]
        ]
    ],
    // ...
]

荣誉列表的URL = 管理面板URL + /honor/honor/list 创建荣誉的URL = 管理面板URL + /honor 用户荣誉列表的URL = 管理面板URL + /honor/honor/user

使用方法

转到添加新的荣誉 Alt text 添加新的荣誉 Alt text 将荣誉添加到用户 Alt text

使用示例

//action 
//honors
    $honors = HonorUser::find()->where(['user_id' => $userId])->with(['honor.translations'])->all();
//
//view
<?php if (!empty($honors)): ?>
    <div class="col-md-12">
            <h3 class="about-user">Honors:</h3>
        <div class="row text-center" style="padding: 2px 10px;">
            <?php /** @var $honor \bl\honors\entities\HonorUser*/?>
            <?php foreach ($honors as $honor): ?>
                <div class="col-xs-4 col-sm-3 col-md-1" style="padding: 0;">
                    <img src="<?= $honor->honor->getImage($honor->honor->image) ?>"
                         width="50" height="50"
                         data-toggle="tooltip" data-placement="top"
                         title="<?= $honor->honor->translation->name ?>">
                </div>
            <?php endforeach; ?>
        </div>
    </div>
<?php endif; ?>

Alt text