Any plans to add support for content structured in Paragraphs?

Issue fork read_time-3043360

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

vollepeer created an issue. See original summary.

muhdmishal’s picture

Hi @vollepeer.

Will be working on this. Meanwhile, it will be very much appreciated if you can provide a patch for this (if you have already done this.)

Thanks

fjgarlin’s picture

StatusFileSize
new2.48 KB

Here is a patch that we used to support paragraphs. I hope it helps.
All credit goes to Tim Clifford (@timclifford). I'm mostly a messenger on his work on this patch.

fjgarlin’s picture

Version: 8.x-1.0-alpha1 » 8.x-1.x-dev
Status: Active » Needs review
tessa bakker’s picture

Status: Needs review » Needs work

After a quick look at the patch...

You could check if the referenced field has an Entity of the type ContentEntityInterface, and loop it again through read_time_calculate(). In this way you can calculate paragraphs in paragraphs or custom entities in paragraphs, etc.

tessa bakker’s picture

Here is the D7 version that can calculate words in paragraphs.

How to use:

  1. Edit the paragraph type and set the fields.
  2. Edit the node type and set the paragraph fields.
  3. Edit a node with paragraphs and save the node to update the time.

Added features:

  1. Paragraph support
  2. Better word count by adding some space
  3. Better word count by using 'safe_value' if available
tessa bakker’s picture

StatusFileSize
new6.43 KB
new2.23 KB

3 small fixes for D7 patch.

Bensbury’s picture

Hi,
I tried applying the patch from #7 for Drupal 7 using two different messages but each time it has failed.

XXXXXX/modules/read_time$ patch -p1 < 3043360-07-paragraphs-support-D7-do-not-test.patch
patching file read_time.install
patching file read_time.module
Hunk #3 succeeded at 227 (offset -22 lines).
Hunk #4 FAILED at 318.
1 out of 4 hunks FAILED -- saving rejects to file read_time.module.rej
XXXXXXXX/modules/read_time$

### Update ###
I didn't see a Dev version listed on the main page but since this a DEV thread for D8 I drush downloaded the D7 version for dev and it exists. This is what you run the patch against from #7.

If this is incredibly obvious, it wasn't to the more dense such as me, so for anyone else the Patch in #7 works for me but make sure you download the DEV version of D7 Read Time and run the patch on that.

Thanks for the patch! Really important to make this usable for a lot of people.

zwerg’s picture

Any work on this Drupal 8 issue?

isaacrc’s picture

Status: Needs work » Needs review
StatusFileSize
new2.46 KB

Reroll #3 Patch to D9 since entity_get_form_display it's deprecated. Tested with the latest dev branch and Drupal 9.1.6

patrick.thurmond@gmail.com’s picture

Ok, I rerolled the #10 patch because we have the same need for a site that uses Bricks instead of Paragraphs. Our organization actually uses both, but primarily Paragraphs. Thus, I am now attaching Bricks functionality to this as a highly useful addendum.

patrick.thurmond@gmail.com’s picture

My last one had one mistake that I hadn't considered. It was calling the render method to get the contents. But doing so passes by reference. This then removes it from the final render array and the field no longer renders on the page. I had been following along the code process in xdebug and missed this simple check.

I have fixed it in this next patch here.

patrick.thurmond@gmail.com’s picture

Further improvements to avoid errors and work more efficiently. This also removes the reference to te build array passed in from the node view hook.

joco_sp’s picture

Version: 8.x-1.x-dev » 2.x-dev
StatusFileSize
new2.16 KB

Reroll of the #10 patch for 2.x version of the module. I did it for this instead of #13, because we are using the patch for quite some time and it worked perfectly for us.

@pthurmond could you do the same for your patch? I'll test it afterwards and commit it if everything will work, because supporting both modules would be great :)

3li’s picture

Status: Needs review » Reviewed & tested by the community

Have been using patch #14 for a while, works well.

introfini’s picture

Patch #14 works well. Thanks!

joco_sp’s picture

Status: Reviewed & tested by the community » Fixed

Thank you all for the support. I merged the patch #14. It will be available in the next release.

Status: Fixed » Closed (fixed)

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