How to you use the gallery template outside of gallery

paulbearne

Joined: 2005-08-01
Posts: 87
Posted: Sun, 2005-08-07 10:03

Hi

I make setup a new site with gallery v2 as the engine

And I need to add a home page along with faq/help etc.

I would like to the gallery template so I only have one set of file to support/edit

How can I do this

Paul

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-08-07 11:31

G2 uses smarty as the template engine. on top of it, we have our own smarty plugins and a lot of stuff. but basically, it's a a unmodified smarty engine.
http://smarty.php.net/

you might be interested in the static html pages module of g2:
http://codex.gallery2.org/index.php/Gallery2:UserContributions#Modules

you could write a FAQ module for g2 (to add new faq entries dynamically) or just use the static html page for it.

if you want to use G2 templates outside G2, you should use GalleryEmbed to initialize g2 and then you can display the resulting page anywhere in your website.

 
paulbearne

Joined: 2005-08-01
Posts: 87
Posted: Mon, 2005-08-08 07:56

Ok I need to run the G2 in as an emdebed gallery

Has abody got any code that pulls the theme out to extnal page with static / otherwise content

Paul :P :P

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-08-08 09:12

see GalleryEmbed::getImageBlock().

It makes something like this:

/* Load the G2 templating engine */  GalleryCoreApi::relativeRequireOnce('modules/core/classes/GalleryTemplate.class');
	    $template = new GalleryTemplate(dirname(__FILE__) . '/../../..'); // this is the path to the gallery root dir
	    $template->setVariable('l10Domain', 'module_' . $moduleId); // this can be omitted, it's for translation
// here you should generate the dynamic content
// then you can let the template know of it by
$template->setVariable('varName', $variable);
		$tpl = 'modules/imageblock/templates/ImageBlock.tpl';  // path to your smarty template
		/* Render and get the page */
		list ($ret, $html) = $template->fetch("gallery:$tpl");
		if ($ret->isError()) {
		    return array($ret->wrap(__FILE__, __LINE__), null, null);
		}
		/* Check for any css required  */
		$head = $template->getVariable('head');
		if (!empty($head['tpl'])) {
		    list ($tpl) = each($head['tpl']);
		    list ($ret, $headHtml) = $template->fetch("gallery:$tpl");
		    if ($ret->isError()) {
			return array($ret->wrap(__FILE__, __LINE__), null, null);
		    }
		}