craft-plugins / nice
一个用于在Craft CMS中展示优秀数据的优秀插件,拥有出色的功能
1.1.0
2022-12-15 08:31 UTC
Requires
- craftcms/cms: ^4.3.3
Requires (Dev)
- ext-iconv: *
- pestphp/pest: ^1.22
- phpstan/phpstan: ^1.8.0
This package is auto-updated.
Last update: 2024-09-15 12:22:07 UTC
README
一个用于在Craft CMS中展示优秀数据的优秀插件,拥有出色的功能。
要求
- Craft CMS: ^4.0
- PHP: ^8.0
安装
要安装插件,请按照以下说明操作。
-
打开您的终端并转到您的Craft项目
cd /path/to/project
-
在终端中运行
composer require awilum/craft-nice
。 -
在控制面板中,转到设置 → 插件,然后点击“安装”按钮进行Nice。
用法
在twig模板中显示优秀的文件大小
//=> 1 MB
{{ niceFileSize(1000000) }}
//=> 976.56 KiB
{{ niceFileSize(1000000, false) }}
//=> 1 MB
{{ 1000000 | niceFileSize }}
//=> 976.56 KiB
{{ 1000000 | niceFileSize(false) }}
在twig模板中显示优秀的数字
//=> 10,050,050
{{ niceNumber(10050050) }}
//=> 10,050,050.00
{{ niceNumber(10050050, 2) }}
//=> 10,050,050/00
{{ niceNumber(10050050, 2, '/') }}
//=> 10:050:050/00
{{ niceNumber(10050050, 2, '/', ':') }}
//=> 10,050,050
{{ 10050050 | niceNumber() }}
//=> 10,050,050.00
{{ 10050050 | niceNumber(2) }}
//=> 10,050,050/00
{{ 10050050 | niceNumber(2, '/') }}
//=> 10:050:050/00
{{ 10050050 | niceNumber(2, '/', ':') }}
在twig模板中显示优秀的日期时间
//=> November 23, 2022, 4:24 am
{{ niceDateTime(1669177469) }}
//=> November 23, 2022, 4:24 am
{{ 1669177469 | niceDateTime }}
在twig模板中显示优秀的文件名
//=> foo-bar
{{ niceFileName('foo bar') }}
//=> foo-bar
{{ 'foo bar' | niceFileName }}
在PHP中使用Nice niceDateTime
函数
use function Awilum\CraftNice\niceDateTime; echo niceDateTime(1669177469);
许可证
MIT许可证 (MIT) 版权所有 (c) Sergey Romanenko