Jump to content

Reading Time


Davyc

Recommended Posts

As we are used to such a busy lifestyle time is a precious commodity.  It would be useful, for Pages content, to have an estimated reading time for each article.  I know this has been done on another platform, but as to the criteria for estimating the time taken to read is something that would need to be calibrated.  Having an estimated time of reading may have a positive impact on whether someone will read an article or skip it if it 'appears' too long.  Thoughts?

Link to comment
Share on other sites

Edit the database template Displate -> Record

Add this anywhere (change the 200 to what you believe the 'words per minute' speed is for someone reading):

{{$wordCount = \str_word_count(\strip_tags($record->_content));}}
{{$estimateTime = \ceil ($wordCount/200);}}

Then add this in your desired place in the template:

Estimated reading time: {$estimateTime} minutes

 

Link to comment
Share on other sites

2 hours ago, Nathan Explosion said:

Edit the database template Displate -> Record

Add this anywhere (change the 200 to what you believe the 'words per minute' speed is for someone reading):

{{$wordCount = \str_word_count(\strip_tags($record->_content));}}
{{$estimateTime = \ceil ($wordCount/200);}}

Then add this in your desired place in the template:

Estimated reading time: {$estimateTime} minutes

 

Brilliant. Who’s going to create a mini plugin hooking into IPS\Content adding a get__readtime method 🔥🔥🔥😂

Link to comment
Share on other sites

4 hours ago, Daniel F said:

Brilliant. Who’s going to create a mini plugin hooking into IPS\Content adding a get__readtime method 🔥🔥🔥😂

I already did this Daniel.

I was going to release it to the public, however due to a hard disk failure, cloud sync error and a drunken night in where I feed large quantities of alcohol into my floppy disk bay, I lost all the code.

You know, all the normally excu... issues we developers face daily.

Link to comment
Share on other sites

Works like a charm, but I had to use the code rather than a custom field as I use @opentype Supergrid plugin and templates and had to add it to the Frontpage entry template.

image.png.af92381cfd49591aa80d9e1872ca7d33.png

The custom field method added the time to the actual article and when choosing the listing option it add the time to the top right of the image and was difficult to read depending on whether the image background matched the text colour.

The tricky aspect of using the code was to find out which template it needed to sit in, but with a bit of detective work using the browser console it was tracked down and works great.

Thanks again to everyone who contributed to the solution, very much appreciated.

Thank U Reaction GIF by BROCKHAMPTON

Link to comment
Share on other sites

16 hours ago, Daniel F said:

Brilliant. Who’s going to create a mini plugin hooking into IPS\Content adding a get__readtime method 🔥🔥🔥😂

As you asked so nicely...pluralized language string included:

Example in Pages:

{$record->get__readtime($record->_content,200)}

image.thumb.png.6985ca5336337c261b4009d42c32dd02.png

 

 

(NE) get__readtime() 1.0.0.xml

Edited by Nathan Explosion
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...