0

I am using Drupal 9 and I have a template which will require 40 text fields and 20 image fields.

They are meant to display 20 individual products, so they are all similar. The display would be something like this -

Product Title 1 Product Thumbnail 1 Product Subtitle 1

Product Title 2 Product Thumbnail 2 Product Subtitle 2

And so on for 20 products.

To add this field manually will take a very long time since it's 60 fields. Is there a module or some other way to duplicate existing fields?

1
  • 3
    Sorry, but this is a terrible idea. Either use an Entity Refeference field and link 20 product content entities or use the Paragraphs module and create a repeatable Paragraph with your 3 fields.
    – Hudri
    Nov 18, 2021 at 16:37

1 Answer 1

3

If you have 20 products, you have 20 things. In Drupal-speak, you have 20 entities.

In Drupal, every "thing" is an entity-- pages (nodes) are entities, and comments are also entities.

Each "thing" should be its own entity type. Drupal provides a lot of tools for linking different entities (such as Entity Reference module) and displaying entities (such as Layout Builder module and Views module). But, all of these tools assume that each "entity" is representing a single thing.

So, if you put 20 products in one entity (node/page), you will prevent yourself from using most of Drupal's features that make it a great CMS.

Instead, I suggest making a custom content type, Product. You can add just three fields to the product:

  • Title
  • Thumbnail
  • Subtitle

Next, create 20 products by adding content of your new content type Product.

Then, create a view using the Views module. This will give you great control over how the products are displayed-- you can make a simple list of products to start, and if you want to expand it later, you can show related products and do many other cool things.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.