Publisher is EE6 compatible, but it does not support the Fluid field. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: Reading Time in Relationship field

Status Resolved
Add-on / Version Reading Time Pro 1.0.3
Severity
EE Version 6.3.4

Avner Wolff

May 25, 2022

Hi Brian

Can Reading Time Pro display the relative value of the {reading_time} field in another channel’s entry in a relationship field that is in a grid field in the relative value?

For example:

This gives me the saved seconds:
{grid_field:relationship_field:reading_time}

But this does not work:
{grid_field:relationship_field:finished_reading_time:relative}

Any ideas, or is this not possible. Maybe I can divide or convert the seconds on the fly into minutes with php.

Thanks
Avner

#1

BoldMinded (Brian)

May 27, 2022

I personally have not tested that, but theoretically it should based on how I know it’s coded. It might be a parsing order issue that is preventing it from working? There is a replace_relative() function in the ft.reading_time.php file. Perhaps put a var_dump() in there to see if it prints anything and if that function is getting called.

#2

Wayne Hultum

Jun 06, 2022

Hi Brian,

I’m also experiencing this issue.

There is no replace_relative() function in ft.reading_time_pro.php

Could you please advise?

Thanks

Wayne

#3

BoldMinded (Brian)

Jun 06, 2022

Can you both verify that the :relative modifier works in a normal channel:entries tag, and it’s only not working when it’s in a grid or relationship field?

Have you tried the module tag? https://docs.boldminded.com/reading-time-pro/docs/template-tags#usage-outside-of-exp-channel-entries-tags

The issue is the fieldtype file isn’t designed to do any of the parsing itself, so I was wrong about the replace_relative() function, it’s been a long time since I’ve looked at this code. It has to wait until the entire entries tag is rendered so it can accurately display the reading time for sub fields, such as Grid, Fluid etc, since those have a different parsing routine.

I’ll take a look at seeing if I can get the :relative modifier to work in the situations you’re describing, but it may be difficult and take some time… few days or a couple of weeks.

#4

BoldMinded (Brian)

Jun 06, 2022

Can you two also verify that the {grid_field:relationship_field:finished_reading_time} is rendering as expected, and it’s just the :relative modifier that is not working?

#5

Wayne Hultum

Jun 06, 2022

Can you both verify that the :relative modifier works in a normal channel:entries tag, and it’s only not working when it’s in a grid or relationship field?

Yes it works as expected in normal channel:entries tag. I’m not using it in a grid field so I can’t comment on that.

If I use the code below it outputs 2 in 2 seconds for each entry

{parents field="media_category"}
{exp:reading_time_pro}
    {reading_time}
    {finished_reading_time:relative}
{/exp:reading_time_pro}
{/parents}

If I use the code below it outputs the corrects seconds and {parents:finished_reading_time:relative}

{parents field="media_category"}
{exp:reading_time_pro}
    {parents:reading_time}
    {parents:finished_reading_time:relative}
{/exp:reading_time_pro}
{/parents}
#6

BoldMinded (Brian)

Jun 06, 2022

Comment has been marked private.

#7

Wayne Hultum

Jun 06, 2022

I’ve download, installed and tested.

Adding all variables to a single entry page results in the following.

{reading_time} =  191

{reading_time:relative} =  52 years ago

{finished_reading_time} = 1654529781

{finished_reading_time:relative} = in 3 minutes

Adding {parents:reading_time:relative} to a relationship is now showing correctly.

Thanks for working on this so quickly.

Login to reply