G2Drupal: Drupal Integration Module
Integrates Gallery2 and Drupal CMS
Author: Dayo Akanji
Download the module files here.
See a demo version here.
Visit the Support Site for enquiries and support requests.
The G2Drupal Module allows users to organise their photos and other multimedia files in Gallery2 while managing other content using Drupal.
The package comes in two folders as follows:
/*
* Session: Find out whether we need to send a cookie & need a new session (only if
* we don't have one yet)
*/
$session =& $gallery->getSession();
$ret = $session->start();
if ($ret) {
return array($ret, null);
}
list ($ret, $shouldCache) = GalleryDataCache::shouldCache('write', 'full');
if ($ret) {
return array($ret, null);
}
if ($embedded) {
$html = $theme->splitHtml($html, $results);
}
Add the following lines above "if ($embedded) {":
/* Added Event: BeforeOutput */
include(dirname(__FILE__) . '/lib/events/Gallery_BeforeOutput.event');
To give:
/*
* Session: Find out whether we need to send a cookie & need a new session (only if
* we don't have one yet)
*/
$session =& $gallery->getSession();
$ret = $session->start();
if ($ret) {
return array($ret, null);
}
list ($ret, $shouldCache) = GalleryDataCache::shouldCache('write', 'full');
if ($ret) {
return array($ret, null);
}
/* Added Event: BeforeOutput */
include(dirname(__FILE__) . '/lib/events/Gallery_BeforeOutput.event');
if ($embedded) {
$html = $theme->splitHtml($html, $results);
}
Problem Solution I get a message saying my username/email is associated with multiple Drupal accounts. You probably bridged an existing instance of the module to a new Drupal installation. You will need to manually disable the module, login into G2 and then uninstall and reinstall the module. Some javascript functionality doesn't work anymore. Do a search online for "Javascript Conflict" and apply the solutions to your conflicting javascript code or contact the author of the relevant javascript code in your Drupal template or plugin and ask them to consider using non conflicting syntax. My site is dog slow when using this module. The notes above offers the suggestion of using the G2 Performance Tips ... read and apply these. I cannot use items with spaces in the names. This is a bug within Gallery2 that affects users of the rewrite module. Basically, Gallery2 themes are generally not specifically written for using the rewrite module.
That is because the rewrite module requires a "urlencode" parameter to be passed with the instruction to create clickable links and Gallery2 themes, including official themes, generally do not include this parameter
This results in invalid urls being generated for items with spaces in the item names when the module is active.
To fix this, open modules/core/GalleryCoreApi.class, find the following line:
function createAlbum($parentAlbumId, $name, $title, $summary, $description, $keywords) {and add the following line immediately AFTER:
$name = str_replace(' ', '_', $name);Similarly, find:
function addItemToAlbumUnder this function, look for
GalleryCoreApi::requireOnce('modules/core/classes/helpers/GalleryItemHelper_medium.class');and add the following line immediately BEFORE:
$itemName = str_replace(' ', '_', $itemName);to replace spaces with underscores in item names, and thus, urls generated.
Item titles will not be affected by these additions.My site is messed up visually when the module is installed. This means you have css conflicts. You will have to manually resolve these.
Note that some Gallery2 themes are more suitable than others. "Matrix" and "Siriux" have been tested to generally work out of the box. "Carbon", on the other hand for instance, is very difficult to use.
There is an option to override CSS files from the module configuration screen within the Gallery2 Site Admin section.
- If you select "Contain Gallery2", the module will look in the module's "data" folder for a CSS file to use in place of the standard "theme.css" file. These should be named using the theme Id (e.g., matrix.css). There are versions distributed for the matrix and siruix themes and if you inspect these, you will notice they include a "#G2Drupal" addition for most of the CSS entries. This helps restrict the theme css to the gallery part of the page. Use such overrides to amend CSS files and leave the actual theme.css intact.
- If you select "Override Gallery2", the module will simply not load any Gallery2 CSS files and only use Drupal CSS files.
- If you select "Override Drupal", the module will load Gallery2 CSS files (including the standard "theme.css" file). As these are loaded last, any CSS they contain will prevail on the page.