Set Gallerypictures programatically


#1

Hello,

I have an object with a Picture Gallery.
Lets call it “Motiv”.

Then I have some other objects, called “Artikel”, where I will store ONE picture for every object.

These “Artikel” are linked to the “Motiv” with an Multi-Href.
Now I want to automatically add the picures from all linked “Artikel” to the Gallery in the “Motiv” object.

How is this possible? The documentation is not really helpful with this.

Cheers,


#2

Hi,
there are to ways to do that:

  1. If you really want to have a gallery data type attribute populated in the motiv-class, you could use event listeners on the article class and update the data in the gallery data type on every save.

  2. If you don’t need to actually populate a data attribute, then you could calculate this information on the fly. For that you could configure a classoverride and provide a custom getter, that returns all images of all articles that are assigned.
    If you need to visualize the images in the pimcore backend too, you could use the layout component preview iframe or text and print out all the images.

I would prefer option 2.

BR
Christian


#3

Hi,

we only work in the pimcore backend. But I’ll try using the iframe method.

Thanks for the help