Gallery2:Themes:Loading Data for Templates - Gallery Codex
Personal tools

Gallery2:Themes:Loading Data for Templates

From Gallery Codex

The Matrix

If you want to focus on changing the layout and style in your theme, but are pretty much satisfied with the content you find in an existing theme, then you shouldn't have to do too much with the PHP code in But if you want to further modify the content that your theme displays, you'll likely need to modify the code. The explanations here make the assumption that you don't know too much about PHP or programming in general. However, knowledge of a small amount of PHP will definitely enhance your understanding of what's going on.

PHP code tag 
Since this file is actual PHP code, the first line of this file must be:
phpDocumentor comments 
Gallery uses a program called phpDocumentor to automatically generate documentation for its code. The comments in that look like the following (beginning with "@" symbols) are there to provide hints for this process. You can add these to your theme code as well if you like.
   * @version $Revision$ $Date$
   * @package Gallery
   * @author Bharat Mediratta <>
   * This implements the standard gallery theme
   * @package GalleryTheme
   * @subpackage Theme
Theme class implementation 
Every theme descends from Gallery's core GalleryTheme. The next line declares the Matrix theme and pulls all of the core Theme functionality into the Matrix theme.
  class MatrixTheme extends GalleryTheme {
the code here initializes your theme, and sets up the objects. The line global $gallery; brings the special $gallery variable into scope for this function so that its contents can be accessed.
       * Constructor
      function MatrixTheme() {
       global $gallery;

The rest of the function simply sets up the theme. When you're creating your own theme, you'd insert the name of your theme into the appropriate places, and modify the settings to suit your needs.

       $this->setDescription($gallery->i18n('Standard Gallery2 look and feel));
       $this->setRequiredCoreApi(array(7, 0));
       $this->setRequiredThemeApi(array(2, 1));
           array('rows' => 3,
                 'columns' => 3,
                 'showImageOwner' => 0,
                 'showAlbumOwner' => 1,
                 'albumFrame' => ,
                 'itemFrame' => ,
                 'photoFrame' => ,
                 'colorpack' => ,
                 'showMicroThumbs' => 0,
                 'sidebarBlocks' => serialize(array(
                       array('search.SearchBlock', array('showAdvancedLink' => true)),
                       array('core.ItemLinks', array('useDropdown' => false)),
                       array('core.PeerList', array()),
                       array('imageblock.ImageBlock', array()))),
                 'albumBlocks' => serialize(array(
                       array('comment.ViewComments', array()))),
                 'photoBlocks' => serialize(array(
                       array('exif.ExifInfo', array()),
                       array('comment.ViewComments', array())))));