Reading Time Plugin for Flextype
Reading Time plugin will help you to know how many readers of every page in your website.
The following dependencies need to be installed for Reading Time Plugin.
Item | Version | Download |
---|---|---|
flextype | 0.9.16 | download |
twig | >=2.0.0 | download |
- Download & Install all required dependencies.
- Create new folder
/project/plugins/reading-time
- Download Reading Time Plugin and unzip plugin content to the folder
/project/plugins/reading-time
Key | Value | Description |
---|---|---|
enabled | true | true or false to disable the plugin |
priority | 100 | Reading Time plugin priority |
Function readingTime()
in namespace Flextype\Plugin\ReadingTime
/**
* Get reading time
*
* @return string
*/
function readingTime(string $content, array $options = []): string
Display reading time with custom translates in the twig templates
{{ readingTime(entry.content, {
'minute': 'Minute',
'minutes': 'Minutes',
'second': 'Second',
'seconds': 'Seconds'
}) }}
Display reading time with custom translates and format in the twig templates
{{ readingTime(entry.content, {
'minute': 'Minute',
'minutes': 'Minutes',
'second': 'Second',
'seconds': 'Seconds',
'format': '{minutes_count} {minutes_label} – {seconds_count} {seconds_label}'
}) }}
Display reading time with custom translates and format that alternative format that hides the minute label in the twig templates
{{ readingTime(entry.content, {
'minute': 'Minute',
'minutes': 'Minutes',
'second': 'Second',
'seconds': 'Seconds',
'format': '{minutes_count} {minutes_label} – {seconds_count} {seconds_label}'
}) }}
Display page view counter in the php
echo Flextype\Plugin\ReadingTime\readingTime($content, $options);
The MIT License (MIT) Copyright (c) 2021 Sergey Romanenko