NextGen Gallery for WordpressMU - necessary modifications
Alex Rabe’s gallery plugin for Wordpress “NextGEN Gallery” is becoming almost as popular as the integration with Gallery2 and with good reason. I run the gallery 2 integration on this blog and it means keeping both systems as well as the integration up to date. IF for whatever reason you want / need all the functionality of gallery2 this is great, but otherwise NextGEN Gallery which is still in beta (i.e. pre version 1) is quickly shaping up as a good alternative.
The best thing about WPMU (for those that don’t know) is that themes and plugins written for Wordpress often require little modification to function - so without further ado…
1. Set the default file path for the plugin so that all images are stored per blog. This function is run on activation when the tables for the plugin are created.
ngginstall.php
function ngg_default_options()
Add
global $blog_id;
Edit options line as follows
$ngg_options['gallerypath'] = “wp-content/blogs.dir/” . $blog_id . “/files/”; // set default path to the gallery
2. Remove ability for user to update the above in the blog backend
settings.php
Remove “gallerypath” from the list of fields submitted to the form - or remove the input box entirely.
3. Modify the version check
nggallery.php
Simply set if (version_compare($wp_version, ‘wordpress-mu-1.2.4′, ‘>=’)) or remove the check entirely
Note
Other changes are required
- If you want to take advantage of disk usage limits per blog and will depend on what method you are using to implement this (we’re using zspace upload quotas)
- You’ll probably also want to hide the plugin’s server status / news display.
- You may want to change / disable the “import image folder” function. Normally you won’t be allowing your users the upload access to need this function.
- The default path is displayed in various pages (such as where a gallery is created) in the backend, you may want to remove this as it probably will not be relevant for your users.
- You may need to edit / remove the permissions checking code depending on how your server is setup
- Kevin Element left a comment below to say “I noticed that when you log in as a user and use the “Uninstall plugin tables” under “setup” it deactivates the plugin for all users.” so that is another feature you’ll wish to look at modifying. Thanks Kevin
Why are you not simply releasing a version of the plugin that works with MU?
Because “works” is relative to how you intend your MU site to function and what other custom code you have installed. The above hacks are the necessary to get the plugin to work on a default MU install. Alex is planning MU support for version one of the plugin - but how best to do this is debatable especially with the addition of things like a role manager and tagging system.
The current discussion on NGGallery for WPMU is here
Rowan :: Aug.24.2007 :: Quick Solutions, Wordpress MU :: 11 Comments »