afzalroq / yii2-cms
Yii2 cms 扩展
1.0.0
2020-12-03 12:41 UTC
Requires
- abdualiym/yii2-language: ^1.0
- kartik-v/yii2-widget-fileinput: @dev
- mihaildev/yii2-elfinder: *
- sadovojav/yii2-ckeditor: dev-master
- yii-dream-team/yii2-upload-behavior: ^1.2.3
- yiisoft/yii2: ~2.0
- zelenin/yii2-slug-behavior: ~1.5.1
Requires (Dev)
- phpunit/phpunit: 4.*
This package is auto-updated.
Last update: 2024-09-22 19:42:47 UTC
README
该扩展允许
- 制作HTML内容块、文件、图片。
- 为标签、分类等选项创建集合
- 为滑块、产品、评论、文章、页面等创建实体
- 支持多达5种语言
- 支持SEO元标签
- 创建具有父子功能的多个菜单
升级说明
- 移除第一个键属性
- 使用语言的第一节点作为firstKey
安装
- 使用composer安装
composer require afzalroq/yii2-cms "^1.0"
- 在composer安装后运行创建表的控制台命令
将自动发现迁移添加到控制台配置
'controllerMap' => [ 'migrate' => [ 'class' => MigrateController::class, 'autoDiscover' => true, 'migrationPaths' => [ '@vendor/afzalroq/yii2-cms/migrations' ], ], ]
php yii migrate/up --migrationPath=@vendor/afzalroq/yii2-cms/migrations
在通用配置文件中设置
CKEditor使用Elfinder插件保存文件和图片。请参阅Elfinder readme进行正确的配置
- 语言索引与数据库列相关。
- 管理面板标签按数组值顺序渲染
- 对于项目、选项和菜单,必须isset common\models\User模型
'modules' => [ 'cms' => [ // don`t change module key 'class' => '@afzalroq\cms\Module', // storage 'path' => $params['storageRoot'], // dirname(__DIR__, 2) . '/storage' 'host' => $params['storageHostInfo'], // 'https://site.example' 'cache' => 'cache', // default cache component name 'cacheDuration' => 3600, // default cache duration 3600 second 'optimized' => false, // set true for get items with options as $item->o // images 'imageOperation' => 'cropResize', 'imageBackground' => 'transparent', 'imageXPos' => 'center', 'imageYPos' => 'center', 'fallback' => $params['storageRoot'] . '/fallback.png', 'watermark' => $params['storageRoot'] . '/logo.png', // i18n 'languages' => [ 'ru' => [ 'id' => 0, // must start from 0 up to 4 'name' => 'English', ], 'en' => [ 'id' => 1, 'name' => 'Русский', ], 'uz' => [ 'id' => 2, 'name' => 'O`zbek tili', ], ], // for add to menu controller actions 'menuActions' => [ '' => 'Home', 'site/contacts' => 'Contacts', ] ], ]
默认使用名为"cache"的缓存组件。配置如下
'components' => [ 'cache' => [ 'class' => 'yii\caching\FileCache', 'cachePath' => Yii::getAlias('@frontend') . '/runtime/cache' ], ]
- 在管理面板中通过链接打开管理
/cms/home/index
添加了Laravels dd()(dump and die)方法
$array = ['a', 'b']; dd($array);
示例
待办事项
- 测试
- 从扩展根目录复制示例小部件到前端集成
用法
在前端使用CController扩展CMSController以正确生成菜单链接
class CController extends CMSController { public function actionCollection(string $c) { } public function actionOption(string $c, string $o) { } public function actionEntity(string $e) { } public function actionItem(string $e, int $i) { } }
单元获取器
Unit::get('slug'); // will return data using cache
项目获取器
\afzalroq\cms\entities\front\OaI::getItemIdsByCollection($slug) : array // of item Ids \afzalroq\cms\entities\front\OaI::getItemIdsByOption($slug) : array // of item Ids
$item->getText1(); // for get Text 1 $item->getText2(); // for get Text 2 $item->getText3(); // for get Text 3 $item->getText4(); // for get Text 4 $item->getText5(); // for get Text 5 $item->getText6(); // for get Text 6 $item->getText7(); // for get Text 7 //for to get meta description and meta keywords just use this command below: $item-registerMetaTags(); //it generates meta tags in your view page
返回文件URI
$item->getFile1(); // for get File 1 $item->getFile2(); // for get File 2 $item->getFile3(); // for get File 3
返回指定格式的日期时间
$item->getDate($format); // for get date with format like "d.m.Y H:i:s"
通过指定的操作返回图像URI(默认 cropResize
)
从文档中查看所有图像操作和示例
// get gallery main photo URI $item->getGalleryPhoto(width, height, operation, background, xPos, yPos) // get gallery photos URI $items->getPhotos() // and use with "foreach(){}" // item photos URI $item->getPhoto1(width, height, operation, background, xPos, yPos); // for get Photo 1 $item->getPhoto2(width, height, operation, background, xPos, yPos); // for get Photo 2 $item->getPhoto3(width, height, operation, background, xPos, yPos); // for get Photo 3
选项获取器
$option->getName(); // for get Name $option->getContent(); // for get Content $option->getPhoto1(); // for get Photo 1 $option->getPhoto2(); // for get Photo 2 $option->getFile1(); // for get File 1 $option->getFile2(); // for get File 2 //for to get meta description and meta keywords just use this command below: $option-registerMetaTags(); //it generates meta tags in your view page
选项和项目搜索
\afzalroq\cms\entities\front\Items::getEntityItemSearchResults((array) $entitySlugs, $search); // get search results with entity and items \afzalroq\cms\entities\front\Items::getOptionItemSearchResults((array) $optionSlugs, $search); // get search results with option and items \afzalroq\cms\entities\front\Options::getOptionSearchResults((array) $optionSlugs, $search); // get search results with options