Gallery2:Modules:g2drupal - Gallery Codex
Personal tools

Gallery2:Modules:g2drupal

From Gallery Codex

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.

Requirements

  • Gallery 2.3.0+
  • Drupal 7
  • PHP 5.0.4+
  • Both Gallery2 and Drupal must be installed under the same document root.


Description

The G2Drupal Module allows users to organise their photos and other multimedia files in Gallery2 while managing other content using Drupal.

  • The module runs within the Gallery2 Framework resulting in a single set of normal Gallery2 URLs. This removes the usual setup of having a separate gallery address from the embedded address. Users can now maintain search engine rankings and can provide direct links to gallery pages.
  • The module is called just before output is displayed after all the normal Gallery2 processes have been run (using a new manually added event) . It then connects to Drupal, retrieves Drupal html output which is then wrapped around the Gallery2 html and this combined output is then displayed.
    A benefit of this is that by using the Gallery2 caching system, previously cached pages can be sent to the user before the module is called resulting in faster speeds and lower resource usage.

Other features are:

  • The Drupal and Gallery2 folders can be located at any offset relative to the other as long as they lie under the same document root.
  • Unified login from Drupal (users logged into Drupal are automatically logged into Gallery2 when user integration is activated). NOTE: Not currently active
  • Unified registration via Drupal when user integration is activated. NOTE: Not currently active
  • Auto points Gallery2 login, logout, account settings and registration links to Drupal when user integration is activated. NOTE: Not currently active

Package Contents:

The package comes in two folders as follows:

  • Gallery2: Contains the following files to be installed in gallery2
    • g2drupal.zip: This contains the Gallery module files.
    • lib.zip: This contains required additional code.
  • Drupal: Contains the following file to be installed in Drupal
    • g2drupal.tar.gz: This contains the Drupal module files.

Notes

  • Install and post bug notifications to the support site. Subscribe to the announcement forum there to receive notifications. You can also subscribe to the forum post at here but this may generate additional emails.
  • Implement the Gallery 2 Performance Tips to improve performance. Similar issues should also be considered on the Drupal side.
  • Make sure you have the Site Administrator registered with the same details on both applications before activating the plugin.
  • The Gallery2 session is subordinate to the Drupal session. If a user is not logged into Drupal, they will be logged out of Gallery2 by the module. Similarly, they will be logged into Gallery2 by the module if logged into Drupal. (Not currently active)
  • Installations of Drupal and/or Gallery2 using one click install scripts or package installers (yum, apt-get e.t.c) are not supported.
  • You can create a full community site by using a similar Fudla Bridge for FUDforum written by the same author.

Installation

Drupal

  • Make sure the Drupal Administrator has the same User Name, Full Name and Email as the Gallery2 Administrator.
  • Log into Drupal as Administrator.
  • Navigate to "Structure >> Menus" and add links to your Gallery 2 site to menus such as the Main Menu and/or the Navigation Menu or any others you wish.
  • Install the g2drupal module (g2drupal.tar.gz).
  • Enable and configure the module. Configuration involves:
    • Entering the full server path to Gallery2
    • Entering the tag to be passed to the Drupal breadcrumb for Gallery2

Gallery2

  • Make sure the Gallery2 Administrator has the same User Name, Full Name and Email as the Drupal Administrator.
  • Log into Gallery2 as Administrator.
  • Make sure the elements required to the installed in Drupal have been completed.
  • If you have previously installed either one of the RefineHTML or JoomG2 modules, make sure they are deactivated as this module cannot be used while either one of those two modules are active
  • Unpack lib.zip into the main gallery2 folder so that the contents are in "gallery2/lib/xyz"
  • Around Line 526 of gallery2/main.php is ...

/*
* 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);
}

  • Unpack the module file (g2drupal.zip) to the "gallery2/modules/" folder.
  • Install, configure and activate the module.


Troubleshooting