Will I need two gallery2 installations to do this?

tomnel

Joined: 2005-05-01
Posts: 31
Posted: Sun, 2005-05-01 22:30

First, thanks for this incredible software.

My situation is this, I have Gallery2 beta 2 up and running great. in my gallery2 I have a photo album and an art/portfolio album. I want to be able to have my normal Gallery2 install and be able to (From my home page) call just the art/portfolio section into a frame in my home page. I want the portfolio section when it is called up this way to not have a sidebar.

I wonder if this is possible.

Thanks for any help.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-05-01 22:54

tomnel, I guess we can accomplish that with GalleryEmbed :)

first, I'd do it without frames.
if your homepage, (where the port folio section of G2 should show up) isn't php yet, make it a php site (just rename .html to .php).
Then, at the place where you want G2 to appear:
(see docs/EMBEDDING for the details)

include('gallery2/embed.php');
GalleryEmbed::init(array(...));
// deactivate sidebar etc.
GalleryCapabilities::set('showSidebar', false);
GalleryCapabilities::set("'showSidebarGreeting',false);
GalleryCapabilities::set('showPathbar', false);
// set it up such that the specific G2 subalbum is shown
$showItem = GalleryUtilities::getRequestVariables('view');
if (empty($showItem)) {
    GalleryUtilities::putRequestVariable('view', 'core:ShowItem');
    // set the correct itemId of the album, CHANGE THIS
    GalleryUtilities::putRequestVariable('itemId', '14');
}
// now render the html
$g2data = GalleryEmbed::handleRequest();
// and display it in your home page
print $g2data['bodyHtml'];
// you could also integrate the css and javascript from G2 with GalleryEmbed::parseHead($g2data['headHtml'])
 
tomnel

Joined: 2005-05-01
Posts: 31
Posted: Sun, 2005-05-01 23:34

Thanks for your help, sorry for being such a newb. I have put the code you gave me in a new portfolio.php page and called it from the home page but it only displays text.

I am studying the EMBEDDING doc and will try to learn more.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-05-01 23:52

change the line:
GalleryEmbed::init(array(...));
to
GalleryEmbed::init(array('embedUri' => 'portfolio.php', 'embedPath' => '', 'relativeG2Path' => './gallery2', 'activeUserId' => ''));

where I assume that portfolio.php is directly in the web root (domain.com/portfolio.php), else change the embedPath.
I also assume that G2 is installed in domain.com/gallery2/, else change relativeG2Path. you'll have to change the include() at the beginning too if G2 is not installed there.

and i haven't tested the code...

 
tomnel

Joined: 2005-05-01
Posts: 31
Posted: Mon, 2005-05-02 00:21

I am getting this error now.

Quote:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/tomnelne/public_html/portfolio.php on line 18

This is the code I have put in portfolio.php

<?php
include('/home/tomnelne/.panel/web/gallery2/embed.php');
GalleryEmbed::init(array('embedUri' => 'portfolio.php', 'embedPath' => '', 'relativeG2Path' => '/home/tomnelne/.panel/web/gallery2', 'activeUserId' => ''));
// deactivate sidebar etc.
GalleryCapabilities::set('showSidebar', false);
GalleryCapabilities::set("'showSidebarGreeting',false);
GalleryCapabilities::set('showPathbar', false);
// set it up such that the specific G2 subalbum is shown
$showItem = GalleryUtilities::getRequestVariables('view');
if (empty($showItem)) {
    GalleryUtilities::putRequestVariable('view', 'core:ShowItem');
    // set the correct itemId of the album, CHANGE THIS
    GalleryUtilities::putRequestVariable('itemId', '14');
}
// now render the html
$g2data = GalleryEmbed::handleRequest();
// and display it in your home page
print $g2data['bodyHtml'];
// you could also integrate the css and javascript from G2 with GalleryEmbed::parseHead($g2data['headHtml'])
}
?>

It seems the line it is having trouble with is

print $g2data['bodyHtml'];

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Mon, 2005-05-02 00:43

Hmmm are you trying to display a album in embedded mode then you should be looking at this G2 API function instead using the ID of the album..

list ($ret, $img) = GalleryEmbed::getImageBlock(array ('blocks' => 'specificItem', 'show' => 'none', 'itemId' => $g2itemid ));
 
tomnel

Joined: 2005-05-01
Posts: 31
Posted: Mon, 2005-05-02 01:14

OK I found the error that was making the page not load, the page is loading now but there is no style/theme applied to the page just the thumbnails on a white page and basic black text. also, when I click on one of the albums it goes back to the default G2 page with the sidebar and everything. shouldn't it keep the settings of the first embedded page?

Thanks again

 
tomnel

Joined: 2005-05-01
Posts: 31
Posted: Mon, 2005-05-02 01:29

Thanks ozgreg, however when I insert that code I am brought to the root of my G2 not the portfolio album. the G2 theme is still missing.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-05-02 09:45

tomnel,
1. what's the itemId of the portfolio album?
2. relativeG2Path is wrong. you entered an absolute path.
- what's the url to portfolio.php
- what's the url to standalone G2?

i made assumptions about these values which are incorrect. please answer the questions, then i can make this script working.

<?php

/* Path to embed.php of G2 */
$includePath = dirname(__FILE__) . '/gallery2/embed.php';
/* path in url to this script, i.e. for example.com/portfolio.php it would be '/'
 * and for example.com/foo/bar.php it would be '/foo/' */
$embedPath = '/';
/* relativeG2Path is the relative path from portfolio to gallery 2 */
$relativeG2Path = './gallery2/';
/* ItemId of the item / album that should be shown */
$itemId = '14';
/* name of this script, you don't have to change this */
$scriptName = substr(__FILE__, strlen(dirname(__FILE__) . '/'));

include($includePath);
GalleryEmbed::init(array('embedUri' => $scriptName, 'embedPath' => $embedPath,
			 'relativeG2Path' => $relativeG2Path, 'activeUserId' => ''));
// deactivate sidebar etc.
GalleryCapabilities::set('showSidebar', false);
GalleryCapabilities::set('showSidebarGreeting',false);
// GalleryCapabilities::set('showPathbar', false);
// set it up such that the specific G2 subalbum is shown
$showItem = GalleryUtilities::getRequestVariables('view');
if (empty($showItem)) {
    GalleryUtilities::putRequestVariable('view', 'core:ShowItem');
    // set the correct itemId of the album, CHANGE THIS
    GalleryUtilities::putRequestVariable('itemId', $itemId);
}
// now render the html
$g2data = GalleryEmbed::handleRequest();

// show error message if isDone is not defined
if (!isset($g2data['isDone'])) {
    print 'isDone is not defined, something very bad must have happened.';
    exit;
}
// die if it was a binary data (image) request
if ($g2data['isDone']) {
    exit; /* uploads module does this too */
}
   
// put the body html from G2 into the xaraya template
$data['bodyHtml'] = isset($g2data['bodyHtml']) ? $g2data['bodyHtml'] : '';
// get the page title, javascript and css links from the <head> html from G2
if (isset($g2data['headHtml'])) {
    list($title, $css, $javascript) = GalleryEmbed::parseHead($g2data['headHtml']);
}
$data['title'] = !empty($title) ? $title : '';
$data['css']  = isset($css) && is_array($css) ? implode('\n', $css) : '';
?>

<html>
<head>
<title><?php print $data['title']; ?> </title>
<?php print $data['css']; ?>

</head>
<body>

<?php print $data['bodyHtml']; ?>

</body>
</html>

this code still doesn't work, because of the wrong itemId and relativePath etc.
but it's more complete.

edit: i've updated the code. it works for me, but it might not be what you want. we'll see.

 
tomnel

Joined: 2005-05-01
Posts: 31
Posted: Mon, 2005-05-02 11:00
Quote:
1. what's the itemId of the portfolio album?

100

Quote:
2. relativeG2Path is wrong. you entered an absolute path.
- what's the url to portfolio.php

tnel.net/v-web/gallery2/

or it can be

tnel.net/portfolio.php

if that is any easier.

Quote:
- what's the url to standalone G2?

tnel.net/v-web/gallery2

Thanks very much for the help.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-05-02 11:34

then replace the lines with the following:

/* Path to embed.php of G2 */
$includePath = dirname(__FILE__) . '/gallery2/embed.php';
/* path in url to this script, i.e. for example.com/portfolio.php it would be '/'
* and for example.com/foo/bar.php it would be '/foo/' */
$embedPath = '/v-web/';
/* relativeG2Path is the relative path from portfolio to gallery 2 */
$relativeG2Path = './gallery2/';
/* ItemId of the item / album that should be shown */
$itemId = '100';

assuming that your portfolio.php is in tomnel.net/v-web/portfolio.php

remember that you don't have to include the css from G2, you can set your own css instead.
and you can change the look of G2 to match your portfolio.php page.

 
tomnel

Joined: 2005-05-01
Posts: 31
Posted: Mon, 2005-05-02 16:26

I see, thanks very much for writing the code. this is probably all very simple for you guys but I am learning how to do this from scratch. the page is loading up! but I just have to learn how to call the css styling.

What about when clicking on an album from my new portfolio page, it goes back to the default G2 layout with sidebar etc...

Here is the page.

http://tomnel.net/v-web/gallery2/portfolio.php

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-05-02 16:58

tomnel, my code assumed you have the url rewrite module deactivated. in that case, it would would. try it yourself. i guess we could it also get to work with url rewrite enabled...

 
tomnel

Joined: 2005-05-01
Posts: 31
Posted: Mon, 2005-05-02 17:24

Great! turned off url rewrite and it is working but would be nice to have rewrite on. only thing now is page is framed in white, do you know why by any chance?

also some of the text formatting is lost from the original page, the text is black and large instead of smaller and grey.

Thanks again.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-05-02 17:33

i assumed the portfolio.php was in /v-web/ and not in /v-web/gallery2/
either move the file or change the paths

/* Path to embed.php of G2 */
$includePath = dirname(__FILE__) . '/embed.php';
/* path in url to this script, i.e. for example.com/portfolio.php it would be '/'
* and for example.com/foo/bar.php it would be '/foo/' */
$embedPath = '/v-web/gallery2';
/* relativeG2Path is the relative path from portfolio to gallery 2 */
$relativeG2Path = '';

 
tomnel

Joined: 2005-05-01
Posts: 31
Posted: Mon, 2005-05-02 17:35

Here is an error, embed path needs to be '/gallery2' to load the main portfolio page however the links to the albums no longer work unless the embed path is '/v-web/gallery2' but when I set it to that the formatting and the thumbnails no longer load.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-05-02 17:41

if you have the file at
http://tomnel.net/v-web/gallery2/portfolio.php

embedPath:
then the path to the file is '/v-web/gallery2/'. this is the embedPath.

relativeG2Path:
the path from http://tomnel.net/v-web/gallery2/ to http://tomnel.net/v-web/gallery2/
this is '' = relativeG2Path

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-05-02 17:43

if you have further questions, please post your current source (or just the top section where the paths are defined).

 
tomnel

Joined: 2005-05-01
Posts: 31
Posted: Mon, 2005-05-02 17:44
/* Path to embed.php of G2 */
$includePath = dirname(__FILE__) . '/embed.php';
/* path in url to this script, i.e. for example.com/portfolio.php it would be '/'
* and for example.com/foo/bar.php it would be '/foo/' */
$embedPath = '/gallery2/';
/* relativeG2Path is the relative path from portfolio to gallery 2 */
$relativeG2Path = '/v-web/gallery2';
/* ItemId of the item / album that should be shown */
$itemId = '100';

Link to page

http://tomnel.net/v-web/gallery2/portfolio.php

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-05-02 17:54

your embedPath is wrong. as i said, set it to '/v-web/gallery2'.
your relativeG2Path is wrong, set it to ''.

 
tomnel

Joined: 2005-05-01
Posts: 31
Posted: Mon, 2005-05-02 17:59

Thanks, it works now.