https://github.com/awilum/craft-nice
A nice plugin with nice functions for nice data representation in Craft CMS.
https://github.com/awilum/craft-nice
Last synced: over 1 year ago
JSON representation
A nice plugin with nice functions for nice data representation in Craft CMS.
- Host: GitHub
- URL: https://github.com/awilum/craft-nice
- Owner: Awilum
- License: mit
- Created: 2022-11-22T11:55:39.000Z (over 3 years ago)
- Default Branch: 1.x
- Last Pushed: 2022-12-15T08:40:50.000Z (over 3 years ago)
- Last Synced: 2024-10-11T03:07:34.572Z (over 1 year ago)
- Language: PHP
- Homepage:
- Size: 20.5 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
Nice plugin for Craft CMS
A nice plugin with nice functions for nice data representation in Craft CMS.
## Requirements
* **Craft CMS**: ^4.0
* **PHP**: ^8.0
## Installation
To install the plugin, follow these instructions.
1. Open your terminal and go to your Craft project:
```
cd /path/to/project
```
2. In your terminal run `composer require awilum/craft-nice`.
3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Nice.
### Usage
Display nice file size in the twig tempalates:
```
//=> 1 MB
{{ niceFileSize(1000000) }}
//=> 976.56 KiB
{{ niceFileSize(1000000, false) }}
//=> 1 MB
{{ 1000000 | niceFileSize }}
//=> 976.56 KiB
{{ 1000000 | niceFileSize(false) }}
```
Display nice number in the twig tempalates:
```
//=> 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, '/', ':') }}
```
Display nice date time in the twig tempalates:
```
//=> November 23, 2022, 4:24 am
{{ niceDateTime(1669177469) }}
//=> November 23, 2022, 4:24 am
{{ 1669177469 | niceDateTime }}
```
Display nice file name in the twig tempalates:
```
//=> foo-bar
{{ niceFileName('foo bar') }}
//=> foo-bar
{{ 'foo bar' | niceFileName }}
```
Use Nice `niceDateTime` function in the PHP:
```php
use function Awilum\CraftNice\niceDateTime;
echo niceDateTime(1669177469);
```
## LICENSE
[The MIT License (MIT)](https://github.com/awilum/craft-nice/blob/master/LICENSE.md)
Copyright (c) [Sergey Romanenko](https://awilum.github.io/)