Using Serendipity with Gallery

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Using Serendipity with Gallery

Post 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!
Last edited by garvinhicking on Wed Nov 24, 2004 4:32 pm, edited 1 time in total.
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
CapriSkye
Regular
Posts: 119
Joined: Sun Oct 31, 2004 4:42 am
Location: Taiwan
Contact:

Post by CapriSkye »

it'd be nice if serendipity works with coppermine too. good work
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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.
Last edited by garvinhicking on Wed Nov 24, 2004 4:32 pm, edited 1 time in total.
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
CapriSkye
Regular
Posts: 119
Joined: Sun Oct 31, 2004 4:42 am
Location: Taiwan
Contact:

Post 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..
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Yes, I'm sorry to have been unclear on that point - but yes, I meant CVS branch-smarty :)

Regards,
Garvin.
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
romulus
Regular
Posts: 49
Joined: Fri Sep 24, 2004 4:31 pm
Contact:

Post 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.
JustinShattuck(dot)com

Not working.

Post 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?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Not working.

Post 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.
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
davecjr
Regular
Posts: 167
Joined: Fri Oct 29, 2004 3:09 pm
Contact:

Post 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
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
gerald

Post 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???
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi gerald.

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

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
gerald

gallery

Post by gerald »

here ya go ...

Powered by Serendipity 0.8-alpha9 and PHP 4.3.2
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: gallery

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
digx

Post by digx »

I've also fully followed the instrutions and get the same issue.

Using alpha 12

Hope you can help. Thanks :)
Post Reply