Skip to content

flextype-plugins/reading-time

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reading Time Plugin for Flextype

Version License Total downloads Flextype Discord

Reading Time plugin will help you to know how many readers of every page in your website.

Dependencies

The following dependencies need to be installed for Reading Time Plugin.

Item Version Download
flextype 0.9.16 download
twig >=2.0.0 download

Installation

  1. Download & Install all required dependencies.
  2. Create new folder /project/plugins/reading-time
  3. Download Reading Time Plugin and unzip plugin content to the folder /project/plugins/reading-time

Settings

Key Value Description
enabled true true or false to disable the plugin
priority 100 Reading Time plugin priority

Documentation

Function readingTime() in namespace Flextype\Plugin\ReadingTime

/**
 * Get reading time
 *
 * @return string
 */
 function readingTime(string $content, array $options = []): string

Usage

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);

LICENSE

The MIT License (MIT) Copyright (c) 2021 Sergey Romanenko