intermundia/yiicms

包包含核心模型、迁移、行为、控制器等。适用于Yii2 CMS

安装: 781

依赖项: 0

建议者: 0

安全性: 0

星标: 3

关注者: 5

分支: 1

开放问题: 5

类型:yii2-extension

v4.0.5 2022-09-12 14:30 UTC

This package is auto-updated.

Last update: 2024-09-12 18:58:24 UTC


README

包包含核心模型、迁移、行为、控制器等,适用于Yii2 CMS

安装

通过composer安装此扩展是首选方式。

运行以下命令之一:

php composer.phar require --prefer-dist intermundia/yiicms "*"

"intermundia/yiicms": "*"

将以下内容添加到您的composer.json文件的require部分。

从单站升级到多站

重要!!!

确保您没有覆盖ContentTree::getActiveTranslationBaseModel::getActiveTranslation方法

  1. console/config.php中添加用户组件

    'user' => [
        'class' => \intermundia\yiicms\web\User::class,
        'enableSession' => false,
        'identityClass' => \intermundia\yiicms\models\User::class
    ]
  2. console/config.php中添加控制器

    'sync' => [
        'class' => \intermundia\yiicms\console\controllers\SyncController::class,
    ],
    'utils' => [
        'class' => \intermundia\yiicms\console\controllers\UtilsController::class,
    ],
  3. common/config/base.php中配置mulsitecore组件。如果您想为不同的环境有不同的域名,最好创建一个忽略文件并将其包含在multisitecore配置中

    'websites' => [
        'website key1' => [
            'defaultContentId' => "content tree id",
            'masterLanguage' => 'en-US',
            "storageUrl" => 'storage url',
            "domains" => [
                'domain1' => 'en-US',
                'domain2' => 'en-US',
            ]
        ],
        'website key2' => [
            'defaultContentId' => "content tree id",
            'masterLanguage' => 'en-US',
            "storageUrl" => 'storage url',
            "domains" => [
                'domain1' => 'en-US',
                'domain2' => 'en-US',
            ]
        ]
    ]

    更新内容:每个域名现在可以对应以下格式的关联数组

    'domain1' => [
        'language' => 'en-US',
        'isProduction' => false,
        'isFrontend' => true
    ]

    完整示例

    'mywebsite.com' => [
        'defaultContentId' => 1234,
        'masterLanguage' => 'en-US',
        "storageUrl" => 'mywebsite.com/storage/web',
        "domains" => [
            'mywebsite.com' => [
                'language' => 'en-US',
                'isProduction' => true,
                'isFrontend' => true
            ],
            'admin.mywebsite.com' => 'en-US', // You can leave en-US as string which means that isProduction and isFrontend both are false
        ]
    ]
  4. 将控制台脚本添加到./migratebash脚本的第一行,以运行核心迁移

    php console/yii migrate --migrationPath=@cmsCore/migrations
  5. 运行迁移

    ./migrate
  6. 从“en”切换到“en-US”语言

    php console/yii utils/switch-language en en-US
  7. 从多站核心网站读取语言并将其插入到语言表中

    php console/yii sync/languages 
  8. 在内容树中添加网站

    php console/yii sync/websites 
  9. frontend/controllers/ContentTreeController设置为扩展核心的FrontendContentTreeController

  1. 当您已经运行php console/yii sync/websites时,复制网站内容

    php console/yii utils/copy-language $fromWebsiteKey $toWebsiteKey $from $to
  2. 在网站内复制语言

    php console/yii utils/add-language $websiteKey $from $to

要更新别名、别名路径和相应的文件管理器项,请运行

   php console/yii utils/fix-alias-and-file-manager-items $websiteKey

SluggableBehavior将更新属于提供$websiteKeycontent_tree_translation表中的每个记录的aliasalias_path属性。相应的file_manager_item记录也会更新。

Usersnap

对于usersnap网站翻译模型有两个参数,usersnap_code,其中应输入从usersnap.com获得的代码,以及type。有3种不同类型

  1. Disabled。在这种情况下,usersnap不会显示
  2. Always display。在这种情况下,usersnap始终可见
  3. Display if url has usersnap=1 in get(如果您想访问usersnap并选择此选项,您应将任何get参数usersnap传递到url一次,这将保存状态到会话中,并显示usersnap,直到会话过期或手动删除)