---UPDATED FOR G2.1.x and G2.2.x- See History for G2.0.x version---
Handy form for doing your work for you: gallery2_embed-o-rator
This is taken from this thread http://galleryproject.org/node/36918.
- Pros
- G2 is always visually embedded in your website no matter what theme you choose.
- You don't have to worry about copying template files into a local folder and possibly losing an important update later.
- You don't have to mess with smarty syntax.
- You have more control over what is displayed (such as removing the login link, etc)
- Cons
- you have to create a new file (not just a customized theme)
- you have to use PHP code and find out what paths you need
- there are suddenly two entry points to your G2, most users may not want that
- the need to do something with cookie paths
- you may have to reset or deactivate your URL Rewrite module
Installation
- You need to create a file called gallery2embedded.php in your gallery2 directory (or anywhere you like) and copy and paste the code below into the file.
- Next you will need to check the paths at the top of the file to make sure they are correct for your installation of gallery2 and the location of your gallery2embedded.php file.
- path = Path to your gallery2 install
- g2Uri = absolute URL path from document root to the Gallery 2 directory
- embedUri = absolute URL path from document root + filename (and any query parameters, but NO path) for access point
- For more information see the EMBEDDING file under the docs directory of your gallery2 install
- Change the HTML code above and below the <?php echo $g2moddata['bodyHtml']; ?> to fit your needs (you can also do a php include to include your header and/or footer files)
- In gallery2 under the site admin page change your cookie path to / and delete your cookies
- In the site admin page, go to Modules and deactivate or reconfigure the URL Rewrite module
- Change your link to g2 to be this new gallery2embedded.php file you created.
<?php
$g2_Config['path'] = dirname(__FILE__) . '/';
$g2_Config['g2Uri'] = '/gallery2/';
$g2_Config['embedUri'] = '/gallery2/gallery2embedded.php';
//print_r($g2_Config);
require_once( $g2_Config['path'] . 'embed.php');
if (!headers_sent()) {
header('Content-Type: text/html; charset=UTF-8');
}
$ret = GalleryEmbed::init(array(
'g2Uri' => $g2_Config['g2Uri'],
'embedUri' => $g2_Config['embedUri'],
'fullInit' => 'false',
'apiVersion' => array(1,0)
));
GalleryCapabilities::set('login',true);
// handle the G2 request
$g2moddata = GalleryEmbed::handleRequest();
// show error message if isDone is not defined
if (!isset($g2moddata['isDone']))
{
print 'isDone is not defined, something very bad must have happened.';
exit;
}
// die if it was a binary data (image) request
if ($g2moddata['isDone'])
{
exit; /* uploads module does this too */
}
if ($ret)
{
print $ret->getAsHtml();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<?php
list($title, $css, $javascript) = GalleryEmbed::parseHead($g2moddata['headHtml']);
echo "<title>" . $title . " -- MySite</title>\n";
foreach ($css as $item) {
echo $item . "\n";
}
foreach ($javascript as $item) {
echo $item . "\n";
}
?>
<style type="text/css"> <!-- /*#gsHeader { display : none; } #gsFooter { display: none; }*/ --> </style>
</head>
<body class="gallery">
<?php
echo $g2moddata['bodyHtml'];
?>
</body>
</html>
Notes
If you have trouble with url rewrites, activate the rewrite rules using the embedded url.