Translations of this page:

Image Gallery Component

This component was designed to allow the rapid display of the most recent images anywhere required within Claromentis.

1. Create file called ComponentImageGallery.php and paste in the following code.

 
<?php
/*
 * A component to fetch the images from the specified album in the image gallery and display them on homepage one after another.
 * 
 * @author Sweta Phatangare [sweta@claromentis.com]
 */
 
class ComponentImageGallery implements TemplaterComponent
{
	/**
	 * Attribute array values:
	 * album_id (int): To specify the album id of Image gallery of which you wish to display the images
	 */
	public function Show($attributes)
	{
		global $db;
		$album_id = $attributes['album_id'];
		
		$res = $db->query("SELECT id, title FROM images where album_id = $album_id ORDER BY RAND()");
		while($row = $res->fetchArray())
		{
			$id = $row['id'];
			$title = $row['title'];
 
			$image = "/intranet/gallery/thumbnail.php?id=".$id."&prefix=small";
			$url = "/intranet/gallery/details.php?id=".$id."";
			$value .= "<a href=".$url." /><img src = $image></a>";
		}
		return $value;
	}
}
?>

2. Copy this file into

/intranet/common/classes/

3. Paste the following component code anywhere on templater file

<component class="ComponentImageGallery">

Suggested location:

/interface_{custom}/main/intranet_home.html  

or

/interface_{custom}/main/right_column.html
 
components/image_gallery.txt · Last modified: 07/06/2011 10:49 by sweta
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki