Gallery2 Integration
r_honey
Joined: 2007-07-24
Posts: 2 |
![]() |
I want to integrate Gallery2 into my site. There are 2 specific areas I am concerned about. 1) My site has different sections. There is a central registration for the entire site. After that, users can choose to register for any section independently. 2) The site has a left, right, top & bottom bars. There's a main content area in the middle which is approx. 680 px wide. I have choosen Carbon as my theme. I want the dynamic sidebar which appears on clicking a link to remain that way, But I want to move everyting else inside the main content area. After some analysis of the Gallery2 code, I have comeout with 2 options: either, dig deep into the code & perform alterations, or simply allow the content to be generated, but just before it is sent to the browser, intercept it. As it is xHTML, I can easily parse it using XML libraries & insert or strip-off desired sections. So, which one is the better choice. Also, can you point me to specific resources that can help me achieve above 2 objectives???? |
|
aldoogy
Joined: 2007-07-16
Posts: 7 |
![]() |
There are a few ways to do this. Here is one technique that I have tried based on an example here http://gallery.menalto.com/files/sample_embedding_wrapper.zip with this method you can just get the data object from a gallery request by collecting the 'themeData' value (i.e. no html layout - so you can do what you want with the data). <?php $data = runGallery(); var_dump($data['themeData']); function runGallery() { require_once('/dev/bin/Apache2/htdocs/gallery2/embed.php'); $data = array(); // if anonymous user, set g2 activeUser to '' $uid = ''; $init = GalleryEmbed::init(array( 'activeUserId' => $uid , 'embedUri' => G2EmbedDiscoveryUtilities::normalizeEmbedUri('/gallerymain.php'), 'g2Uri' => G2EmbedDiscoveryUtilities::normalizeG2Uri('/gallery2/') )); $g2moddata = GalleryEmbed::handleRequest(); if(!isset($g2moddata['isDone'])) { $data['bodyHtml'] ='isDone is not defined,something very bad must have happened.'; return $data; } // exit if it was an immediate view / request (G2 already outputted some data) if($g2moddata['isDone']) { exit; } $data['themeData'] = isset($g2moddata['themeData']) ? $g2moddata['themeData'] : ''; return $data; } ?> WARNING: this is actually totally raw and untested code that I have knocked together quickly - it may not work off the bat - but it is just to give an idea how to intercept data before it is rendered by the gallery template. There is also the full embed method that get you access to the core API - and then you don't need to start editing G2 code (which I advise against - hacking the code may give quick results but could prove to be a nightmare to maintain). do full embed like this . . . $init = GalleryEmbed::init(array( 'fullInit' => true , 'activeUserId' => $uid , 'embedUri' => G2EmbedDiscoveryUtilities::normalizeEmbedUri('/gallerymain.php'), 'g2Uri' => G2EmbedDiscoveryUtilities::normalizeG2Uri('/gallery2/') )); Now you can make calls to Core API typically like this list ($ret, $item) = GalleryCoreApi::loadEntitiesById(7); if($ret) { echo $ret->html(); // print an error if there was one exit; } var_dump($item); // print a dump of what we just got
when doing the full embed you don't need to bother with GalleryEmbed::handleRequest(). |
|
r_honey
Joined: 2007-07-24
Posts: 2 |
![]() |
Exactly, I myself did not want to work with G2 code directly. You say that might give quick results, but my experience says that hacking into that code would take a lot of time and patience, for a product of that complexity. Anyways, I am not looking to do that, so let's put that aside. Thanx for the reply... |
|