承接 zaengle/craft-readtime 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

zaengle/craft-readtime

最新稳定版本:1.0.2

Composer 安装命令:

composer require zaengle/craft-readtime

包简介

Craft Read Time

README 文档

README

Readtime provides a new Field Type called Read Time. When added to an entry, the field will loop through all of the content fields and calculate the estimated read time of the text content and save the value for use on the front end. The Read Time field will update every time the Entry is saved.

Settings

The Words per Minute value used to determine read time can be changed in the plugin settings. The default is set to 200 words per minute.

How to Use

Create a new field with the Read Time field type and add it to your page Entry Type. The Read Time value will automatically update when the Entry is saved. If you save content within a CKEditor longform entry block, you will need to also save the parent entry to update the Read Time value.

To display the field on the front end, call the field in the template by the field handle and apply the filter of the desired display:

Human

This is the default display type. It will automatically format the time in hours, minutes, and seconds. If hours or minutes do not apply, they will be excluded from the display.

{{ entry.fieldHandle }}
{{ entry.fieldHandle.human }} 

Example: 211 seconds will display as 3 minutes and 31 seconds.

Simple

Same as the Human display but the seconds will be excluded. The minutes will round to the nearest minute.

{{ entry.fieldHandle.simple }} 

Example: 211 seconds will display as 4 minutes.

Rounded

If the Read Time is under a minute or over an hour, the display will get rounded. Otherwise, it will show the Simple value. Under a minute will display "Less than a minute". Over an hour will round the minutes to the nearest 5 minute value.

{{ entry.fieldHandle.rounded }} 

Example: 55 seconds will display as Less than a minute.

Example: 3840 seconds will display as 1 hour and 5 minutes.

DateTime

Outputs the Read Time value as a date/time value that can be formatted.

{{ entry.fieldHandle.dateInterval|date('%h hours, %i minutes, %s seconds') }} 

Example: 211 seconds will display as 0 hours, 3 minutes, 31 seconds.

Content Updates

If the field is added to a section after content is added, the content will need to be resaved to fill the Read Time field value. To resave a whole section at once, use the CLI command:

craft resave/entries --section sectionHandle

If you have a lot of entries and want to add it to the Craft queue, add the --queue flag to the command.

Compatibility

The Read Time plugin will work on both Craft 4 and Craft 5. Currently, there is only support for Craft native fields and CKEditor.

Read Time Roadmap

  • Tests
  • Update Longform logic when CKEditor v5.0 is released

Brought to you by Zaengle Corp

统计信息

  • 总下载量: 751
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-02-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固