Simple working example of minimal embedding

yelvington

Joined: 2003-08-07
Posts: 14
Posted: Wed, 2005-03-23 19:35

I'm trying to do something that should be simple but is apparently not.

<?
header('Content-type: text/plain');
require_once('gallery2/bootstrap.inc');
require_once(dirname(__FILE__) . '/gallery2/embed.php');

GalleryEmbed::init();

$params = array( 'blocks' => 'randomImage|recentImage|viewedImage',
         'show' => 'title|date|views|owner|heading|fullSize' );
$content = GalleryEmbed::getImageBlock($params);
								         
if ($content) print_r($content);

GalleryEmbed::done();
?>

What I get back is a massive dump of obscure error messages, and no actual content. What should I be doing differently?

All I want is blocks, not integration with the login system, et cetera, for this particular purpose.

My real goal is to get the FOUR latest, FOUR most popular, et cetera. Even if I get getImageBlock working properly, can it do what I want, or should I start digging into the database myself?

 
yelvington

Joined: 2003-08-07
Posts: 14
Posted: Wed, 2005-03-23 19:39

Oh, I should have added: The error messages end with "Fatal error: Call to undefined function: render() in /htdocs/gallery2/modules/core/classes/GalleryTemplateAdapter.class on line 265"

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Wed, 2005-03-23 20:17

that error makes it sound like the item it picked wasn't an image.. it would help to see the stack trace. one error in your code.. should be: list ($ret, $content) = GalleryEmbed... followed by if ($ret->isError()).
this method should work.. you could also use the external imageblock method described in Site Admin / Random/Popular
imageblock only returns one of each type.. rather than going to the db it would be great if you could add a parameter for how many you want and submit a patch.. we'll gladly roll that into the codebase.

 
yelvington

Joined: 2003-08-07
Posts: 14
Posted: Thu, 2005-03-24 13:19

Thanks for the pointer to the external imageblock method. I knew I had seen it someplace but I was looking without success in the docs/ directory.

I'm a procedural kind of guy trying to survive in an object-oriented world, but if I do code a solution I'll offer it up. :-)

For the time being, I'm trying the external imageblock method you suggested. I can retrieve the block in a loop until I get four different random results, then filter out some of the hardcoded html (table width of 144 pixels, for instance) and combine the results into a new display of four side-by-side images. I'll cron the process rather than doing it on the fly, for performance reasons.

This solves my problem for "show four random images," but it doesn't get me where I really want to go, which would include four-up panels for "top ranked galleries, order by views desc" so in the long run extending the codebase would be preferable.

I can't show the site I'm developing, because it's under lock and key until launch, but if you look at how Yafro clusters images on the homepage you'll get the general idea of where I'm trying to go.