Questions tagged as ['paragraphs']

Use it for questions relating to the Paragraphs module, not for text or body paragraphs.
Score: 1
Kevin avatar
Delete millions of unused Paragraphs and their data?
in flag

We have a site that after a few years has built up 10 million records in the paragraphs_item table. This is a result of lots of data migrations (where paragraphs are involved) and there are many orphans now (probably 90% of that).

Entity Reference Revisions ships with a Drush command now to 'purge' orphaned entities. This does appear to work - but with this many to look through it seems like it w ...

Score: 1
Giuseppe avatar
How to hook on paragraph deletion?
br flag

I'm on D9 and I've a paragraph inside a content type node.

I need to hook when the paragraph is deleted to do some custom logic and set up a queue.

I've tried hook_entity_delete, hook_entity_predelete or hook_paragraph_delete, hook_paragraph_predelete: those hooks run during cron, if the node containing the paragraph is deleted.

However, it seems to me those aren't triggered if an existing paragraph ...

Score: 1
Baud avatar
How to validate a paragraph field?
sa flag

I have a paragraph type with 2 fields: year and quarter

I have a content type with a paragraph field (field_year_and_quarter) targeting ONLY this paragraph type

I am trying to create a constraint to disallow the encoding of a duplicate (same year/quarter)

I have tried:

1-A constraint at the node level which is looping into field_year_and_quarter with $node->get('field_year_and_quarter')->reference ...

Score: 0
How to make pagination for php data inside preprocess_paragraph_HOOK
ru flag

I have data coming from External Entity (MongoDB) and I need to make pagination inside hook theme suggestion of a paragraph :

code snippet

Is there a way to use built-in pagination of Drupal in this scenario? thanks!

Score: 0
user3038672 avatar
Extending block, a block with a paragraph field, and 3 paragraph fields... how to loop through the paragraphs from the block extension
cn flag

This is what I have:

I have three twig files:

  1. block--paragraph-images.html.twig (which extends block.html.twig)
  2. field--field-paragraph-image-block.html.twig (the paragraph field which is located in the custom block type, block--paragraph-images.html.twig.)
  3. paragraph--field-paragraph-image.html.twig (which houses three fields: field_paragraph_image, field_paragraph_title, and field_paragraph_text ...
Score: 0
Kevin avatar
Deleting a Paragraph Item results in AJAX POST error "Missing bundle property on entity of type node."
in flag

Working with an older D7 site. On it, we have added the latest version of Paragraphs to add some content items to a page. This all works fine.

However, when trying to remove a Paragraph Item from the form, you get an AJAX error. The root of it is:

EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 8006 of /mnt/www/html/moswebsandbox1/docroot/include ...
Score: 1
How to display all data from a paragraph field in views (Drupal 7)
ae flag

I am currently a caretaker for a Drupal 7 website and I can't figure out how to group paragraph items in views. I have created a content type Products and one of the fields is called product variation which is field type paragraphs. I have created a paragraph bundle for that field.

Then I created a view to show the products on the front page. To display the paragraph fields I created a content re ...

Score: 0
liquidcms avatar
How to pass Paragraph ID from Layout Builder to Views?
us flag

This is a bit convoluted; so hopefully it makes sense:

I have a parent entity: Event. Event has a Paragraph field on it: Sessions (paragraph type: Session).

I use Layout Builder to format the Full Content view mode of the Event. In the layout I add a (paragraph) view which lists the Session paragraphs as Teasers (view mode of Session) with a contextual filter of Paragraph: Parent ID. This all works ...

Score: 0
user3038672 avatar
Trying to access a "count" variable inside a block field from paragraphs template
cn flag

I'm trying to get the number of paragraphs an authenticated user inputs by counting them in the parent block template and trying to access that number in the paragraphs template. I have two templates I'm working with:

  1. field--field-hover-image-block.html.twig
  2. paragraph--hover-images.html.twig

The paragraphs are being loaded through the paragraph entity field in a custom block. I'm counting the numb ...

Score: 0
abelass avatar
Custom validation constraints multi value paragraphs : how to get weight value
nl flag

I am validating a multi value paragraph field using constraints.

/**
 * Implements hook_entity_bundle_field_info_alter().
 */
function cnfpt_internet_entity_bundle_field_info_alter(&$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle) {
  if ($bundle === 'manifestation') {
    if (isset($fields['field_occurence'])) {
      // Add a validation.
      $fields['field_occurence'] ...
Score: 0
abelass avatar
Custom constraints validation of multi value paragraphs: highlighting missing field
nl flag

I am using constraint for the validation my multi value paragraph field.

I can correctly implement the different validation rules but I haven't found out how to highlight only the erroneous field(s).

Here is my violation declaration

      $this->context
       ->buildViolation($constraint->modaliteRequise)
       ->atPath((string) $delta . 'subform.field_modalite.0')
       ->addViolation( ...
Score: 1
Edoardo Cordani avatar
How can I access the parent entity values inside a custom paragraph formElement?
in flag

I created a select custom field that must be inserted inside a paragraph and the options values are dynamically inserted based on another reference field present in the paragraph itself. How can I access the actual paragraph instance to read the value of the reference field, so I can manage the right values inside the formElement function of the custom field?

Score: 0
Geat avatar
Last item missing for multiple fields when editing a node
de flag

I'm using a multiple paragraphs field on a node.

I noticed that each time I saved the node and then edited it again, the last item (delta n-1 with delta starting at 0) would disappear. If I clicked on the Add new button, it would repopulate with the content of the missing field. However, if I saved without taking any further action, the next last field would disappear.

I dug around in the module code, ...

Score: 0
Using Tac Lite in combination with Paragraphs
ma flag

For our new Drupal 9 (or 8 if necc.) website we require a very fine controllable access structure where we can give and restrict access on a user by user basis. Not only for a content type but also for the paragraphs (or more atomic components of a page). With Tac Lite we can already set the permission via taxonomy terms on a user bases to view a node. But now we would like to also controll single parag ...

Score: 1
scaffolding avatar
Accessing node value in paragraph twig template
es flag

I'm writing a twig template for a paragraph. I'd like to access a text field value from the page/node where this type of paragraph will be added.

Specifically, I'd like to access the value of a text field titled 'field_runner_id'. I access this value in my page/node twig template like this:

content.field_runner_id|field_value

I've tried a handful of techniques (listed below) to access that field value wi ...

Score: 0
Is there a way to make a single type Paragraphs field not required?
sr flag

My Content Type has a Paragraphs field that is Not required. The Paragraph type has a required field for when it is added, but until it is added, this shouldn't trigger "required" for my field. Since my field only has 1 paragraph type option, it is ALWAYS added! I can Remove the paragraph from the field, and required doesn't get triggered. But every time the form loads to add a new node, it always adds  ...

Score: 1
blur avatar
How can I assign custom field layouts using paragraphs?
bn flag

For reference:

-modules
--contrib
---ds
--custom
---ds

I'm looking to add paragraph layouts using flexbox. I don't see a module specifically for this, so I realize I'm going to have to adapt an existing module.

Right now, I'm trying to add custom layouts in the Display Suite module by adding a template config to ds.layouts.twig with the appropriate html.twig and css files.

My concern is that any e ...

Score: 0
Md. Shafiq Hossain avatar
How to access paragraph fields from a webform's form?
cn flag

I have a webform (contact_info) which is attached to a paragraph's field (field_contact_info). The paragraph has other fields as well.

I implemented hook_form_alter() to change some attributes inside the webform's form.

Is there any way to access the values of other paragraph fields value in hook_form_alter()?

I can pass them inside the webform object, but those aren't available in hook_form_alter()

Score: 0
ProGrammar avatar
Paragraphs removed from graphql schema if not anywhere in content, which causes error for union type
ca flag

I'm making a headless Drupal site with Gatsby using paragraphs. I'm experienced with Drupal but relatively new with gatsby/graphql.

The issue I'm running into is that if our database does not actually have any instances of a paragraph, then it generates the schema without that (i guess it generates a minimal schema based on what exists, not what types are actually possible) and it errors out beca ...

Score: 1
Editing paragraphs field settings returns 404 with php development server
ve flag

I have this strange behaviour on my local drupal9 instance. I start it in the web folder with the build in php development server: php -S localhost:8000

Now if I try to edit any paragraphs field, eg. /admin/structure/paragraphs_type/manual_news/fields/paragraph.manual_news.field_news_entries

[Fri Aug 13 12:47:39 2021] 127.0.0.1:55544 [404]: POST /admin/structure/paragraphs_type/manual_news/fields/paragra ...

Score: 1
metalac avatar
Where should I include method to pass current selection to entity browser select view?
us flag

I'm following this guide https://drupal.stackexchange.com/a/277898/56676 which I found very useful. So, I understand where the first function goes, but when it comes to the method public function getArgument(), I'm not sure where this function should be included?

Considering that we don't have a custom widget, we are using entity browser in configuration.

So, do we need to create custom widget, plu ...

Score: 0
Change paragraph object for rendering
mx flag

I have a paragraph type with a node ref field that, if you leave it empty, is supposed to show a random node using some defined logic.

I have the code to do the query and get the node, and ideally I'd want to put it on the paragraph object in some pre-render hook so that the paragraph can render normally using its usual config. Something like this (warning: pseudo-codish):

function mymodule_paragraph_ ...
Score: 2
Kevin avatar
Add ThirdPartySettings to individual paragraphs of a certain bundle?
in flag

I want to add configuration settings to Paragraph entities in a specific bundle in Drupal 8. Theres potentially a lot of options and the need to change/update them over time, so I figure the best way is through ThirdPartySettings and not adding more fields to it. I am going to use these values to influence certain aspects of the render and for search queries.

I can see where you can add settings  ...

Score: 0
Interlated avatar
What is the token for the file download link of a media entity?
km flag

Using the linked_field module and the [paragraph:field_pbpresentation_file:entity:url] token, I get the edit link for the media entity, not the link to download the file itself.

What token should I use for the download link?

Score: 0
Andrew Perriman avatar
How do I set up a views block that filters contextually on a field included in a paragraph?
in flag

I have two content types (ContentA, ContentB) which both use the same paragraph (MyParagraph) as field type “Entity reference revisions.”

MyParagraph consists of two “List (text)” fields: ParagraphFieldA, ParagraphFieldB.

The values for ParagraphFieldA and ParagraphFieldB come in both cases from allowed values lists which have a key and label.

ContentA is limited to one MyParagraph reference bu ...

Score: 0
Ruzanna Hovasapyan avatar
How to programmatically add a paragraph item to a user account?
cn flag

I already added the Check in/out History field to the user account, which has the check-in date and check-out date fields.

How can I programmatically add new items to Check in/out History?

I need to create some history for users.

Check-in date Check-out date
04/05/21 05/07/21
03/05/20 04/14/20
Score: 0
Hubert avatar
How can I build a specific data structure?
cn flag

I have a Course content type which has several "modules." (A module is just a name.) There are also several "units," which may or not belong to a module. A unit has several fields, for example Location, Description.

I have created a Course unit paragraph type, and a Units field in the "course" content type, which references this paragraph type. That way I can create units that belong to the course.

Score: 0
ARUN avatar
How do I migrate a nested paragraph field?
fi flag

I have a wrapper paragraph, Layout (para_layout), which has the following fields.

enter image description here

I created the same paragraphs and field structure in a Drupal 9 website. I created the following custom migration plugin.

id: custom_para1
label: Custom paragraph migration
migration_group: custom
migration_tags:
  - node
source:
  plugin: d7_paragraphs_item
  bundle: para_layout
process:
  field_left_column: fie ...