Recent Changes - Search:




Summary: How to embed the Menalto Gallery
Version: 0.2 (27 February 2005)
Maintainer: James McDuffie
Categories: Images, Integration


To describe how one user was able to embed the Menalto Gallery inside of PmWiki.


NOTE: Proceed at your own risk!

This recipe assumes you are starting off with an unmodifed version of Gallery. If you have customized your Gallery install already, then please be careful and do not overwrite your changes with mine. Also, these changes were made to Gallery 1, I have not tried out Gallery 2. The changes should work with just any version 1 Gallery.

This is not going to be simple modification because to get this working requires some ugly hacks.

  • Download and unpack the zip file located in the files section of this recipe. This zip file can not just be dropped in place (sorry). It contains some drop in code and some files that just contain code segments.
  • Upload the files gallery/html_wrap/wrapper.footer and gallery/html_wrap/wrapper.header from the zip file to the html_wrap directory of your Gallery installation. Make sure that you do not overwrite any custom modifications you have already made. These two files form the meat of the embedding:
    • wrapper.header - Turns on output buffering so that everything output by Gallery can be saved into a variable
    • wrapper.footer - Does all the work of displaying Gallery with your PmWiki style. It sets up custom view handler and then sources the pmwiki.php file so that it performs the page displaying.
  • Take a look at the file gallery/config.php from the zip file. This file contains templates for the variables that need to be added to your config.php file. You need to modify the following variable:
    • $PMWIKI_BASE_DIR - Point this to where pmwiki.php is stored
Optionally if you are using my UserAuth software, set up the following variables. If you don't use UserAuth you can probably ignore them:
  • $HTPASSWD_CODE_DIR - Point this to where the HtPasswd.php class is stored
  • $HTPASSWD_FILE - Point this to the .htpasswd file used for your UserAuth install
  • You may now need to modify the util.php file in your Gallery installation. I had to change one line of code so that URL rewriting would be active even though the Gallery is embedded. The way we have embedded Gallery still allows URL rewriting to function. I had to change this line:
	if (!$GALLERY_EMBEDDED_INSIDE && $gallery->app->feature["rewrite"]) {
To this:
	if ($gallery->app->feature["rewrite"]) {
  • Upload the file pmwiki/local/register_globals.php from the zip file to the local directory under your PmWiki installation. This file basically is a hack to get around the fact that when we load the pmwiki.php code from inside of Gallery the variable scopes is different and hence all of PmWiki's global variables are no longer global. Does that make any sense? Any ways this file is loaded by Gallery and sets up all the global variables that PmWiki will need. NOTE: Your installation of PmWiki may have more global variables than listed in my version. If so then you need to generate your own register_globals.php file. To do this, modify your pmwiki.php code so that it outputs the Php $GLOBALS array after all config files have been loaded and it is just about to call the read handler.

The code to do this is something like this:

  foreach(array_keys($GLOBALS) as $g) {
     print "global \$$g;<BR>";

Place the above code right before the following line in pmwiki.php


Make sure to edit out all the global variables that do not look like WikiWords.

If you are having problems with your embedding of Gallery within PmWiki then it is most likely the result of a global variable not being included in register_globals.php. If you are having a problem then you probably need to create your own version of this file.

  • Look at the file pmwiki/local/config.php from the zip file. It contains the following snippet of code that you need to put in your PmWiki config.php file. It basically senses that PmWiki is being called from inside of Gallery and sets the browse handler appropriately. Also note that the code points to a Gallery specific PmWiki style template. You can use your existing template but it is going to have unnecessary items such as "Edit" and "Page History" links that do not make any sense when Gallery is displayed. To make your own template just copy your existing one and remove the parts that don't make sense.
  • And I think that about wraps it up. There may be some parts that try to access my UserAuth code. If those cause you problems then simply remove them. I have tried to document everything I did. If I have forgotten something then please help me figure it out and fix this recipe!

Optional for using Gallery with UserAuth:

  • Upload the directory classes/pmwiki from the zip file to your Gallery's classes directory. You should not have to modify this code as long as you set up the variables mentioned earlier in the config.php file correctly.
  • Look at init.php from the zip file and seach for "pmwiki" in that file. The case statement for pmwiki should be added to your init.php. This case statement tells Gallery to use classes that utilize my UserAuth software for handling logins. Do not just overwrite your init.php with my version since you are probably running a different version of Gallery than I am.


This recipe may not work for you perfectly the first time. You are going to have to get your hands dirty and actually change code in various places. It could get messy. But if you do find that part of this recipe is wrong or has caveats then please help out by fixing this page! I hope this solution works out for you, but I do not guarantee that it will.


You can see an example of this recipe in action at my LookGallery. -- JM

If you get this working then please post your example here.



If you make updates to this recipe then please update the history here.

November 24, 2004 - Version 0.1 - Initial release of recipe. -- JamesMcDuffie
February 27, 2005 - Version 0.2 - Updated for use with PmWiki Version 2 -- JamesMcDuffie



See discussion at EmbeddedGallery-Talk

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.

Edit - History - Print - Recent Changes - Search
Page last modified on September 03, 2012, at 07:30 AM