Problem/Motivation
There is no way to reuse a paragraph itself.
People still have requested it or even implemented it in the paragraph entity.
#2568601: Add label and description properties on paragraphs bundles and [#]
If i have a common paragraph that should be present across multiple contents...
Proposed resolution
Optionally make paragraphs reusable somehow.
I guess this only makes sense for a few paragraphs, thus they should be promoted as "reusable".
Possibly, reusable paragraphs need to be precreated in a separate paragraph content overview?
Remaining tasks
#2843917: Implement Library entity type
#2847049: Add bundle sync to library items
#2847051: Render the re usable paragraph when editing
#2847053: Convert a normal paragraph into the library
#2858036: Convert a library item into a paragraph
#2847054: Create demo content for paragraphs library
#2847055: Display usage number of library items
User interface changes
API changes


| Comment | File | Size | Author |
|---|---|---|---|
| #19 | upload_11_15_2016_at_10_12_06_AM.png | 122 KB | drobnjak |
| #19 | upload_11_15_2016_at_10_11_50_AM.png | 68.02 KB | drobnjak |
Comments
Comment #1
scoff commentedInteresting idea but personally I don't like all the complications it might lead to.
I think I have a solution:
Try to add another field of entity reference type and select your paragraph bundle as a target entity type. You could even use a paragraph for it.
Paragraph bundle "paragraph" — actual content, many fields (reusable).
Paragraph bundle "existing paragraph" — just entity reference(s).
Content type "some node" — add a paragraph field with both paragraph types selectable, so you can add a new content or select existing.
Haven't tried this, though.
Comment #2
ivan zugec commentedHave you looked at Replicate paragraphs? I've never used it.
https://www.drupal.org/project/replicate_paragraphs
Comment #3
jeroen.b commented@Ivan Zugec this issue is tagged 8.x-1.x-dev, the replicate module is for Drupal 7
Comment #4
miro_dietikerNice. Didn't know something like this exists.
At least we have some idea from D7. :-)
Comment #5
miro_dietikerNote that with the entity_reference_revision field currently, this would result in trouble.
If a reusable paragraph would be updated, the using nodes would still point to previous revisions.
Thus, reusable paragraphs would need to be referred without revision id... which means to always use latest revision.
Comment #6
jeroen.b commentedTrue. And honestly, I don't really want to fix this in Paragraphs.
If you want to re-use paragraphs, it's better to create the content that you want to re-use somewhere else (like with a content type). And then refer to it with a entity reference inside a paragraph type.
That's also what we do with media (scald), so why not with content?
Making re-usable paragraphs messes up the whole reason we made this module: usability.
Comment #7
miro_dietikerI understand the argument of using a different content entity. And we could create a paragraph wrapper of type "Reusable content" with a further entity reference... possibly even using the entity browser to browse or add a new one.
But for the use case of reusing a "paragraph" in the mindset of a user (and not any known other entity) i have the feeling this direction makes the UI more complicated.
People asked me immediately about reuse when i have shown them paragraphs.
No need to take actions or decisions now. I would keep it as common feature request open... And one day we can also offer some best practice recommendation if the feature won't be provided by paragraphs on its own.
Comment #8
miro_dietikerI recently found multiple references about making paragraphs reusable. Including:
https://www.commercialprogression.com/post/paragraphs-are-drupals-answer...
Note also that people compare Paragraphs with Atoms that offers reusability / considers it a key concept. ;-)
https://www.drupal.org/project/atoms
Comment #9
marcoscanoInteresting and related discussion: #2250393: Reuse Paragraphs items + Give more power to end-user
Comment #10
miro_dietikerWe decided that paragraphs are embedded / composite by design and separately maintain them is against our architecture.
The composite relationship will be cleanly managed by ERR in #2641824: Maintain composite relationship
Thus, reuse needs a separate entity where metadata such as labels makes sense.
For paragraphs itself though, we will not support it ever.
I'm leaving this issue still open as a feature request and updating the issue summary.
See also #2601096: Merge with Bricks / Atoms where i hope collaboration and reuse can evolve.
Comment #11
miro_dietikerFrom Paragraphs workshop:
Not a common use case, possibly also because it's not really supported out of the box.
But for advanced Paragraphs based strongly content driven applications, it can be very helpful.
Examples: Testimonials or predefined marketing statements to place the same multiple times accross a site.
Slashrsm mentioned there is overlap with Media projects and other entities.
We discussed some examples to understand why an own entity makes sense:
Block have probles with cluttering admin UI because each block instance appears.
Node based approaches need rabbithole and search exclusion.
The Media entity is usually not used for this kind of content.
Note that a custom entity type would sync bundles and fields. Each paragraph type would automatically also have a corresponding reusable type. Thus we can easily convert paragraphs back and forth, without the need to build the reusable types and configure a mapping.
Comment #12
damienmckennaWe went through similar problems with Fieldable Panels Panes recently where the default was to make them reusable, and how that tied into revisions and using them with Panelizer when the node the display was attached to was going through a revision process. We eventually settled on the decision that reusable entities could not be tracked as part of the parent entity's workflow and the latest revision would always be loaded, otherwise the Staypuft Marshmallow Man would come a stomping.
Comment #13
akalata commentedIn practice, I'm already using custom entity types/bundles (via ECK) and entity references to manage the content bits that I want to reuse. The problem with the earliest "solutions" in this thread is then the next step - I want to be able to create a single paragraph entity that has this reference, and reuse that same paragraph across nodes. Creating a new paragraph entity each time means I'll have N identical entities, referencing the content to be reused. So while the content isn't being duplicated, the configuration/glue/connection piece still is.
I'm going to continue down that path just because I don't see any other way to do it without dealing with everything discussed above -- just wanted to elaborate a bit of detail on the initial request.
Thanks @DamienMcKenna for chiming in here with a similar experience -- I would agree with the expectation that if I'm pulling in content from "somewhere else" I should always see the latest version of that content. Since I'm already using entity references, the expectation is a bit clearer from the content admin side; if the paragraph was available to be actively edited in the admin side (like a wysiwyg field), I could see there being confusion on which paragraphs are shared/global and which ones are unique/revisionable.
Comment #14
damienmckennaOne kludgy way of handling it might be to have a Paragraph type that references a custom entity type/bundle (e.g. blocks or ECK objects), so then the referenced object can be reusable and it can still be used inside an entity_reference_revision / Paragraphs field.
Comment #15
miro_dietiker@DamienMcKennna: That's the whole idea. Let me explain in a bit more detail.
But we want to make this separate entity type:
- Autosync with bundles + fields of Paragraphs
- Still add a label (plus more administrational fields if needed for managing them).
A reusable paragraph will be typically stored as a clone of a previous paragraph. It is NOT a composite of the original.
Reusable paragraphs have an own separate edit form and can also be creted independently through the Add form.
A user can click the action "Add to library" that makes a paragraph reusable.
This clones the paragraph and the original host entity will have a new paragraph instance added that contains a reference to the effective reusable paragraph.
The paragraph type "From Library" contains nothing but a entity reference to the reusable paragraph.
Initially, using autocomplete widget here is fine.
Comment #16
Frando commentedWouldn't a simpler way be to create an entity type "reusable paragraph" with a single bundle only and just two field: label and a entity reference revision field to reference a paragraph?
And then also a paragraph type "Reuse from library" that has a (regular, not revisioned) entity reference field to reference "reusable paragraphs".
Then, when editing content, there'd be a button next to each paragraph saying "Make paragraph reusable". When clicked:
- A new "reusable paragraph" entity is created
- The paragraph that has been clicked to be made reusable is attached to that new entity
- In place of the now moved paragraph, a new paragraph of type "Reuse from library" is added that references the new entity
Same procedure to pick from library directly (Add paragraph of type "Reuse from library", then possibly with entity_browser integration for the "reusable paragraph" entity).
This way, no need to sync fields.
Comment #17
miro_dietiker@Frando Yeah agree. This might fit better in simplicity.
It adds one limitation though. We only create one bundle (in case you need extra fields for management of the library).
Say, you might want to create extra fields to browse your huge collections of testimonials, thus attach terms... while that term field doesn't make sense to classify other paragraph types.
This classification might only make sense in the library as when simply creating the paragraphs inline it's unneeded management field clutter.
Keep in mind, this needs to be made for huge collections with rich data types.
So while not syncing fields (through putting an ER field) we might still need to sync bundles to make use of bundles.
One caveat is, now a reused paragraph involves 3 entities inside the host entity with the ERR paragraph field:
- The paragraph entity that represents the reused placement with the ER field
- The library entity with label with an ER field
- The paragraph entity containing the content
So that's one entity more. Hope we will still perform well in complex datasets.
Comment #18
miro_dietikerComment #19
drobnjak commentedComment #20
cllamas commentedI think this is a great idea and much necessary in many of the cases that one wants to use paragraphs.
Comment #21
johnchqueAdded remaining tasks.
Comment #22
kirkilj commentedAt the time I'm making the reference to reusable content, I'd want to be able to indicate, via the UI:
* whether I want to use the latest or a specific revision of the referenced library entity
* whether I want to just grab a copy of it or a reference to it
If it's a reference,
* whether I want an embedded and rendered entity or a link to the original
Specific Question: How does one pick a library item? I have the paragraphs_collections module and I see code for paragraph_library. Is there a browser to refer to library items or even paragraphs within the same content instance (page)? Where is that nicely designed draggable paragraph outline in the screenshots by drobnjak in #19 above? Or is this a mock-up?
Comment #23
miro_dietiker@johnkirkilis The screens you have seen are mockups. The implementation is a first step. And there are many follow-ups to improve. Both picking an item and converting an item is not yet implemented.
Also we have decided that with our initial version:
- Everywhere you use the library it points to the latest version (an entity reference, not an ERR field!)
- The user is made aware that the change affects all usages immediately.
Note that ERR doesn't offer a selection widget that allows a user to pick the used version or even make the user aware of the fact that it points to an outdated version. Also, maintaining workflows as you wish is more related to the Drupal core workflow initiative.
Once tools are reliable and available, we can look into how we want to deal with it.
A follow-up (we will postpone it) would be great.
Picking an item and clone it is how Templates (a concept on top of the library) works. We want to avoid mixing the two cases:
Picking a library item makes it a reference. Picking a library item that is marked as being a template, will clone it.
#2826687: [META] Introduce Templates
The mockups are misleading. What you see is the drag&drop mode that will be introduced here:
#2825575: Introduce a Drag & Drop Mode
But this mode will likely not offer the conversion action. Instead it is offered in regular edit/collapsed mode.
Comment #24
toncic commentedNew follow-up from converting paragraphs item into library: #2856568: Allow editing label (title) while converting paragraph item to library
Comment #25
toncic commentedComment #26
ginovski commentedAdding related.
Comment #27
pasqualleI guess everyone is using entity reference to a custom entity by now..
We are using the box module as a custom entity. Box can be cloned (there is a submodule for that). It seems we are creating more boxes than paragraphs even if we do not reuse them.
And of course you can put paragraphs inside a box, so in some cases we have a structure like:
node > paragraphs > box > paragraphs > box.. But I must tell, that is not user friendly.
Comment #28
miro_dietiker@Pasqualle We have added the Paragraphs Library module in the most recent release. It's a first step towards optional reusability with some basic transformation workflows (into the library and back to unlink from the library). That's a great start and time to assess additional requirements so we can put the priorities right to make this more mature.
I didn't know the Box module, so i would like to hear a bit more if it has some advantages to the library in the current version.
Comment #29
hanoii#2847051: Render the re usable paragraph when editing would be amazing.
Is there any current momentum happening on the library/reusability part of paragraphs?