Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the Custom fields text to the counter #27

Open
patatagit opened this issue Oct 20, 2022 · 2 comments
Open

Add the Custom fields text to the counter #27

patatagit opened this issue Oct 20, 2022 · 2 comments

Comments

@patatagit
Copy link

plg_readingtime does not counts the text included in custom fields.
The follow code add the Custom fields text to the counter


JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php');
$row->jcfields = FieldsHelper::getFields('com_content.article', $row, true);
foreach($row->jcfields as $jcfield){
$fullArticle .= $jcfield->rawvalue;
}
Could you add this fix in the next version?
Thanks

@carcam
Copy link
Owner

carcam commented Oct 20, 2022

Hi @patatagit
Thank you very much for your contribution!! You are right, we are not considering custom fields if they are not embedded in the article text.

My approach to this is that we cannot provide an exact amount of time or progress for the article as there are so many cases... So the reading time is an estimation based on the main content of the article.

Your suggestion will do great in some sites where they just use text fields or textareas, but if you are using a subform field type, probably it will provide weird results.

Nevertheless I myself have thought several times to ditch the article content and offer the author just custom fields to create their content, so considering custom fields sounds like a good idea to me.

To have a better idea on your case, can you please provide more context on your case? I'm sure we can get a good addition to the plugin from this.

Thanks!!

@patatagit
Copy link
Author

Hi carcam,
you are right, some fields are different from text or textarea but in the most of case this fields contain a few string of code, I think they do not affect the counter significantly.
A solution could be to add an option in the configuration in order to include/exclude all the custom fields in the count of time. Selecting only the text fields could be a difficult task.

Have a nice day

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants