lionel-m / galerie

[No longer maintained] Galleria extension for the Contao CMS
5 stars 2 forks source link

Multiple gallerias in one article #14

Closed abias closed 9 years ago

abias commented 9 years ago

Hi,

in a project of mine, I had the need to place multiple gallerias in one article, one below the other.

Unfortunately, in the frontend, only the first galleria loads. The second galleria only shows small thumbs of the images. And there is a debug message in the javascript console saying:

Uncaught TypeError: Cannot read property 'length' of undefined galleria-1.4.2.js:4026 Galleria.destroy galleria-1.4.2.js:4026 (anonymous function) galleria-1.4.2.js:6897 x.extend.each a134e398ffb2.js:2 x.fn.x.each a134e398ffb2.js:2 $.fn.galleria galleria-1.4.2.js:6893 Galleria.run galleria-1.4.2.js:5914 (anonymous function) das-projekt.html:1

Is this a problem of the contao plugin or of the galleria framework? Are you able to fix this for contao?

Thanks, Alex

abias commented 9 years ago

Hi, do you have any idea what the problem with multiple gallerias might be?

Thanks, Alex

lionel-m commented 9 years ago

Sorry but my computer is broken and I cannot make tests at the moment... But can I see the problem online?

lionel-m commented 9 years ago

I can not reproduce this error. I tested three Gallerias on the same page with success.

abias commented 9 years ago

Hi,

sorry for my big delay getting back to you.

I can confirm that multiple completely different gallerias work on the same page.

What I want to do is to place multiple gallerias onto one page which are sharing the same galleria template (defined on /contao/main.php?do=galerie), only differing in the pictures being displayed. This does not work with the error described above.

Are you able to reproduce the error with this constraint? If not, I will provide you a demo page.

Thanks, Alex

lionel-m commented 9 years ago

What I want to do is to place multiple gallerias onto one page which are sharing the same galleria template

Each gallery is defined by a unique ID and that is why it is not possible to have multiple identical galleries on a page. You have to duplicate your galleries...

I suppose you use the option "Add several images from one or more folders" always with the same gallery in a content element or a module. But the ID is created in the gallery with basic preferences and is always identical.

abias commented 9 years ago

Hi,

your assumption is right, I am using the option "Add several images from one or more folders". The reason behind this is that I have prepared a galleria template and our editors need only to use this template and add their images without fiddling with galleria settings. I think this is quite reasonable.

I understand your explanation what's going on at the moment and what is causing the problem, but I can't understand why this problem is inevitable. Duplicating galleria templates is no solution to the problem for us.

Could it be feasible to add some random number to the unique ID for each galleria when working with the gallery IDs?

lionel-m commented 9 years ago

Could it be feasible to add some random number to the unique ID for each galleria when working with the gallery IDs?

Currently, the identifier is created like this: id="{alias}-{galleryID}". I did this to avoid having two identical ID in the HTML structure. But now it will be id="{alias}-{cteOrModuleID}". This is the module ID or the content element ID that is used and therefore it is never the same. You suggested a good solution :)

But the risk now is that if a user has used the ID to make a theme or modifications with CSS, the extension update will have a very unpleasant effect... CSS will be modified accordingly.

abias commented 9 years ago

Thanks for the change! I see the downside of the changed IDs, but I think it's a minority group of users and one should know that thinks can break if you rely on system-generated IDs in CSS.

Would you mind publishing the new version in the Contao plugins repository so that the plugin can be updated from the Contao backend!

Many thanks!

lionel-m commented 9 years ago

Hi, Yes the update is now available in the ER.

abias commented 9 years ago

Thanks, Lionel. Now everything is working for me as expected :)