I would like to get the read time value per node in my view which displays nodes.

Read time is not available as field and doesn't seem to appear in the node object.

Any idea how to achieve this ?

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Jibus created an issue. See original summary.

yivanov’s picture

Hi, Read time is an extra field, which is added to the View display of the content types. If you use rendered output on your views, you will be able to display the reading time.

jibus’s picture

Status: Active » Closed (won't fix)

Thank you !

I use fields, so not the best way to get the reading time but with a regex I managed to get it.

I think an integration with https://www.drupal.org/project/extrafield_views_integration module would be great !

rar9’s picture

getting this Reading Time added to views displayed as Fields would be great so it will work for Drupal 9 as well.

chrisck’s picture

@Jibus I'm interested to know how you got node_read_time to work in a view with fields? Can you share the regex you used?

jibus’s picture

@chrick, this is quite ugly.

I create a view template : views-view-fields--MYVIEW.tpl.php. The field "description contains the read time (in french).

<?php preg_match('/(.*) minutes/', $fields['description']->content, $matches); ?>
<span class="badge m-l-10 pull-right"><i class="icon-clock"></i> Lecture de <?php print $matches[1]; ?> minutes</span>
chrisck’s picture

Thanks for sharing and interesting approach.

MauHG made their first commit to this issue’s fork.

mauhg’s picture

Status: Closed (won't fix) » Needs review

Made a merge request to add the node read time as a field to views.
https://git.drupalcode.org/project/node_read_time/-/merge_requests/1

  • yivanov committed e5498e9 on 8.x-1.x authored by MauHG
    Issue #3165914: How to get read time value in a view
    
yivanov’s picture

Thank you for your contribution, @MauHG ! :)

yivanov’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.