- Status changed to Postponed: needs info
about 2 years ago 12:01pm 19 January 2023 - First commit to issue fork.
- Assigned to Grevil
- Status changed to Needs work
almost 2 years ago 1:35pm 3 May 2023 - 🇩🇪Germany Grevil
Ok, I sinked quite a bit of time in this issue now, and I am still unsure on what to do here. Generally speaking, I thought at first the problem was the incorrect invocation of the hook, I never saw "moduleHandler->alter" before and only ever used "invoke" and "invokeAll" instead. The description of the method is also very vague, leading to my conclusion, that this is the wrong approach AND the hook was missspelled ("photoswipe_js_options" instead of "photoswipe_js_options_alter"). Turns out, its just fine!!
The only problem is really the "themeManager->alter" call. We can easily alter any options, through defining a hook inside a module file. Defining the hook inside a theme however does NOT work. I am still unsure why.
This entry here: https://drupal.stackexchange.com/questions/157381/theme-hooks-vs-module-... states, that a module needs to check for other themes, which implement the hook itself. But the code referenced is not present in core any more.
Also the test inside https://git.drupalcode.org/project/photoswipe/-/blob/3.2.4/tests/themes/... is useless, as it doesn't really check the "REAL" photoswipe options.
- last update
almost 2 years ago Composer require failure - @grevil opened merge request.
- 🇩🇪Germany Grevil
@Anybody should decide on how to continue from here, if we still want to enable the modification of the photoswipe options through a custom theme, or if defining it through a module file could be already enough.
- 🇩🇪Germany Anybody Porta Westfalica
I guess the method isn't implemented correctly.
See: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Theme%21T...
- 🇩🇪Germany Anybody Porta Westfalica
Important:
Ensure you implement the hook in the correct active theme!
$theme = $this->getActiveTheme();
Typically you'll use photoswipe in the frontend, so it will be your default frontend theme!
If you're rendering PS in the backend, I guess it's the admin theme. - Status changed to Closed: works as designed
almost 2 years ago 2:24pm 3 May 2023 - 🇩🇪Germany Grevil
My bad, had the wrong theme activated...
So everything works as expected, no need to make any changes.
@hop, check the page type where the Image Gallery is loaded. If it is an admin page, your admin theme should have the hook implemented. If it is a "normal" page, your default theme should implement the hook.
- Status changed to Closed: cannot reproduce
almost 2 years ago 2:24pm 3 May 2023 - 🇩🇪Germany Anybody Porta Westfalica
We've just tested this extensively and can definitely say it works as expected!
The described issue can't be reproduced, the issue seems to be a human one :)