If per-album theme and theme settings are not flexible enough for your needs, you can register an event listener to override the theme that should be used to display the current view (page).
/* Define a event listener to decide what theme to use */ class MyThemeEventListener /* extends GalleryEventListener */ { function handleEvent($event) { global $gallery; $data = $event->getData(); $item = $event->getEntity(); if ($gallery->isEmbedded() && $data['viewType'] == VIEW_TYPE_SHOW_ITEM) { $themeId = 'nzdi'; } else if {$data['viewType'] == VIEW_TYPE_ADMIN) { $themeId = 'matrix'; } else { // Let it use configured theme for this request $themeId = null; } return array(null, array('themeId' => $themeId)); } }
/* In module.inc */ function performFactoryRegistrations() { return GalleryCoreApi::registerFactoryImplementation('GalleryEventListener', 'MyThemeEventListener ', 'mymoduleid', 'modules/mymoduleid/classes/MyThemeEventListener.class', 'mymoduleid', array('Gallery::LoadThemeAndParameters')); }
/* In your integration code */ $ret = GalleryEmbed::init(...); ... /* The path is only relevant if the event listener (class MyThemeEventListener) isn't already defined. */ $ret = GalleryCoreApi::registerFactoryImplementationForRequest('GalleryEventListener', 'MyThemeEventListener ', 'myintegration', '/../relative/path/to/my/integration/integrationCode.php', 'myintegration', array('Gallery::LoadThemeAndParameters')); ... $data = GalleryEmbed::handleRequest(); ...
Note that there is also the easier, but less flexible alternative:
/* In your integration code */ $ret = GalleryEmbed::init(...); ... $ret = GalleryEmbed::setThemeForRequest('siriux') ... $data = GalleryEmbed::handleRequest(); ...
The event has been introduced in core API 7.40 / embed API 1.3.
The returned value is an associative array with the following keys:
To override theme parameters, it makes sense to let users configure the theme settings to be used as override. Take a look at the keyalbum module (modules/keyalbum/KeywordAlbumSiteAdmin.inc) to see how a theme settings page can be shown, handled and how the settings can be stored.