schere软件/cake-cms

CakePHP 3 的基于块的网站内容管理系统

安装量: 6,216

依赖者: 0

建议者: 0

安全: 0

星星: 4

关注者: 4

分支: 5

开放性问题: 0

类型:cakephp-plugin

v1.1.0-alpha 2018-10-11 08:32 UTC

This package is auto-updated.

Last update: 2024-09-12 05:01:40 UTC


README

License

CakePHP 3 的基于块的网站内容管理系统

安装

在您的 config/bootstrap.php 中加载插件

Plugin::load('Cms', ['bootstrap' => true, 'routes' => true]);

将 CMS 小部件资源的 Dispatcher 过滤器添加到您的 config/bootstrap.php 中的相应部分

DispatcherFactory::add('Cms.WidgetAsset');

通过迁移插件添加表

bin/cake migrations migrate --plugin Cms

将配置添加到您的 config/app.php

'Cms' => [
    'Administration' => [
        'layout' => 'Admin.default', // Layout to use for the CMS admin area
        'helpers' => [
            'CkTools.Menu' // Helpers to load in the CMS admin area
        ]
    ]
]

配置前端渲染 CMS 页面的路由(使用此示例并根据您的需求进行修改)

$routes->connect('/:slug', Configure::read('Cms.Frontend.renderAction'), ['routeClass' => 'Cms.SlugRoute']);

使用页面属性

可以定义任意页面属性来保存 CMS 页面的额外数据,而不必修改 CMS 架构。数据将作为 JSON 保存在 cms_pages.page_attributes 字段中。

CMS 将在您的 CMS 配置的 Pages.attributes 路径中查找。配置看起来像这样

'Pages' => [
    'attributes' => [
        'public' => [
            'type' => 'boolean',
            'label' => 'Publicly Available',
            'default' => true
        ],
        'keywords' => [
            'type' => 'text',
            'label' => 'Keywords',
            'default' => ''
        ]
    ]
]

基于此配置,输入字段将在编辑屏幕的单独“属性”标签中渲染。可以使用 CmsPage::getAttributes()CmsPage::getAttribute($attribute) 后续获取属性。

示例

    $this->loadComponent('Cms.Cms', [
        'permissionsCallback' => function (CmsPage $page) use ($controller) {
            return $page->getAttribute('public');
        }
    ]);