Page 1 of 4

Using Serendipity with Gallery

Posted: Mon Nov 08, 2004 1:26 pm
by garvinhicking
This is a HowTo on displaying Gallery (http://gallery.sf.net/) inside the Serendipity layout.

Usually, one would embed gallery into Serendipity; but this causes some trouble with all the URLs and would affect many files to be edited.

Thus I used a way to let Gallery include the Serendipity framework.

1. You need at least Serendipity 0.8-alpha3 for this method to work. This development version uses Smarty and makes it easier to include foreign content.

2. Install Gallery

3. Install Serendipity

4. Edit your "config.php" file of the Gallery installation. Set those variables:

Code: Select all

$gallery->app->embedded_inside_type = "Serendipity";
$gallery->app->serendipity_dir = "/your/path/to/serendipity/";
5. Edit the "init.php" file of the Gallery installation. Find the code with this switch:

Code: Select all

	/* Okay, we are embedded */
	switch($GALLERY_EMBEDDED_INSIDE_TYPE) {
There you add a new PHP case:

Code: Select all

case 'Serendipity':
    include(dirname(__FILE__) . "/classes/gallery/UserDB.php");
    include(dirname(__FILE__) . "/classes/gallery/User.php");

    /* Load our user database (and user object) */
    $gallery->userDB = new Gallery_UserDB;

    /* Load their user object with their username as the key */
    if (isset($gallery->session->username) && !empty($gallery->session->username)) {
        $gallery->user = $gallery->userDB->getUserByUsername($gallery->session->username);
    }

    $serendipity_directory = $gallery->app->serendipity_dir;

    $cwd = getcwd();
    chdir($gallery->app->serendipity_dir);
    define('S9Y_INCLUDE_PATH', $gallery->app->serendipity_dir);
    include_once(S9Y_INCLUDE_PATH . 'serendipity_config.inc.php');
    include_once(S9Y_INCLUDE_PATH . 'include/functions.inc.php');
    include_once(S9Y_INCLUDE_PATH . 'include/plugin_api.inc.php');
    include_once(S9Y_INCLUDE_PATH . 'include/plugin_internal.inc.php');

    $serendipity['smarty_file'] = 'index.tpl';
    $serendipity['smarty_raw_mode'] = false;
    serendipity_smarty_init();
    $serendipity['smarty']->assign(
        array(
            'leftSidebarElements'       => serendipity_plugin_api::count_plugins('left'),
            'rightSidebarElements'      => serendipity_plugin_api::count_plugins('right')
        )
    );

    chdir($cwd);
    ob_start();
break;
6. Create a new file "deinit.php" inside your Gallery installation directory. Use this content:

Code: Select all

<?php serendipity_smarty_shutdown($gallery->app->serendipity_dir); ?>
7. Edit the file ".htaccess" of your Gallery installation. Insert this value at the end:

Code: Select all

php_value auto_append_file /full/path/to/gallery/deinit.php
The last two steps are necessary, because Gallery does not share the concept of a common append file where Serendipity can wrap the generated content, so we need to do it with our own file.

Steps 4 and 5 may become part of the official Gallery distribution once Serendipity 0.8 will be out.

I have only tested basic functionality; there may still be parts not working perfectly. Feedback appreciated!

Posted: Mon Nov 08, 2004 2:17 pm
by CapriSkye
it'd be nice if serendipity works with coppermine too. good work

Posted: Mon Nov 08, 2004 3:07 pm
by garvinhicking
CapriSkye wrote:it'd be nice if serendipity works with coppermine too. good work
The same concept is applicable to Coppermine:

1. You need at least Serendipity 0.8-alpha3 for this method to work. This development version uses Smarty and makes it easier to include foreign content.

2. Install Coppermine Gallery

3. Install Serendipity

4. Select a template from Coppermine you want to use. Edit the "template.html" file of that directory. Remove everything before <body> and everything after </body> (the <body> tags need to be removed as well!)

5. From the same Coppermine template directory, open the 'theme.php' file. Insert this at the very beginning of the file:

Code: Select all

/* SERENDIPITY HOOK START */
    $serendipity_directory = '/path/to/serendipity';

    $cwd = getcwd();
    chdir($serendipity_directory);
    define('S9Y_INCLUDE_PATH', $serendipity_directory);
    include_once(S9Y_INCLUDE_PATH . 'serendipity_config.inc.php');
    include_once(S9Y_INCLUDE_PATH . 'include/functions.inc.php');
    include_once(S9Y_INCLUDE_PATH . 'include/plugin_api.inc.php');
    include_once(S9Y_INCLUDE_PATH . 'include/plugin_internal.inc.php');

    $serendipity['smarty_file'] = 'index.tpl';
    $serendipity['smarty_raw_mode'] = false;
    serendipity_smarty_init();
    $serendipity['smarty']->assign(
        array(
            'leftSidebarElements'       => serendipity_plugin_api::count_plugins('left'),
            'rightSidebarElements'      => serendipity_plugin_api::count_plugins('right')
        )
    );

    chdir($cwd);
    ob_start();
/* SERENDIPITY HOOK END */
Pay attention that you need to modify the $serendipity_directory setting!

6. Create a new file "deinit.php" inside your Coppermine Gallery installation directory. Use this content:

Code: Select all

<?php serendipity_smarty_shutdown($serendipity_directory); ?>
7. Create a file ".htaccess" of your Coppermine Gallery installation. Insert this value:

Code: Select all

php_value auto_append_file /full/path/to/cpg/deinit.php
Again, only basic functionality has been tested. You will need to also modify the Serendipity Template you have chosen to include the CSS code from your original Coppermine-Template. Or you need to modify the "templates/default/index.tpl" file of Serendipity to contain a call to the CSS stylesheet of Coppermine.

I have not looked into the Coppermine port for PHPNuke; this may have better ways of embedding foreign content.

Regards,
Garvin.

Posted: Tue Nov 09, 2004 12:00 am
by CapriSkye
thanks, i will give it a try later. but are you talking about the version for smarty branch? i can't find 0.8-alpha3..

Posted: Wed Nov 10, 2004 9:51 pm
by garvinhicking
Yes, I'm sorry to have been unclear on that point - but yes, I meant CVS branch-smarty :)

Regards,
Garvin.

Posted: Sat Nov 13, 2004 9:51 pm
by romulus
worked for me, but apparently my settings in config.php for embedding weren't read by gallery. So I had to set the variables to embed gallery in init.php to make it work. Maybe a bug in gallery, I don't know.

Not working.

Posted: Wed Dec 01, 2004 3:36 pm
by JustinShattuck(dot)com
I followed the instructions above, and I guess I borked something -- as usual.

Internal Server Error when I attempt to view my gallery.. how am I supposed to embed it? or will users access it via my gallery/ directory?

Re: Not working.

Posted: Wed Dec 01, 2004 4:00 pm
by garvinhicking
Yes, they will access it via gallery/ directory.

If you get en Internal Server Error your apache does not allow setting an php auto prepend file and you need to let your server admin change that (AlloweOverride All).

Regards,
Garvin.

Posted: Sun Dec 05, 2004 4:52 am
by davecjr
What if nothing seems to happen! I think I followed the instructions correctly and nothing seems different when I go into my gallery. It didn't even break! I'm using gallery v1.4.4-pl2 and s9y 8 alpha 4

Posted: Sun Dec 05, 2004 11:00 pm
by garvinhicking
If nothing happens it seems that your Apache Server does not support the php_value auto_append_file option...I did not put enough effort into looking for alternative ways to emulate such behaviour with hacking init.php or whatever. Gallery does not support a 'file which is loaded at the end' portion, so it is hard to achieve without the .htaccess mechanism.

Regards,
Garvin

Posted: Sun Dec 26, 2004 4:10 pm
by gerald
Hi,

I followed all setps and get:
Fatal error: Call to undefined function: serendipity_smarty_shutdown() in /var/www/html/gallery/deinit.php on line 1

at the bottom of the gallery page.

WHY???

Posted: Tue Dec 28, 2004 2:19 pm
by garvinhicking
Hi gerald.

Did you install Serendipity 0.8 ? The function is only available there.

Regards,
Garvin

gallery

Posted: Sun Jan 02, 2005 7:02 pm
by gerald
here ya go ...

Powered by Serendipity 0.8-alpha9 and PHP 4.3.2

Re: gallery

Posted: Sun Jan 02, 2005 8:13 pm
by garvinhicking
Okay, if you're using it, you should be able to use it.

Have you followed the rest of the instructions and patched the init.php file so that Serendipity is loaded? That doesn't seem to be the case, because the required function seems to not be available...

Regards,
Garvin

Posted: Mon Jan 31, 2005 10:39 pm
by digx
I've also fully followed the instrutions and get the same issue.

Using alpha 12

Hope you can help. Thanks :)