We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2611
    • 394 Posts
    We needed this snippet for a client, so have fun with it if you need it too smiley
    This one shows a breadcrumb trail for the current album your in (fetches parent until 0)

    <?php
    /**
     * GalleryBreadCrumb
     *
     * Copyright 2010 by Shaun McCormick <[email protected]>
     * GalleryBreadCrumb snippet by Patrick Nijkamp (aka b03tz) <[email protected]>
     *
     * Gallery is free software; you can redistribute it and/or modify it under the
     * terms of the GNU General Public License as published by the Free Software
     * Foundation; either version 2 of the License, or (at your option) any later
     * version.
     *
     * Gallery is distributed in the hope that it will be useful, but WITHOUT ANY
     * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
     *
     * You should have received a copy of the GNU General Public License along with
     * Gallery; if not, write to the Free Software Foundation, Inc., 59 Temple
     * Place, Suite 330, Boston, MA 02111-1307 USA
     *
     * @package gallery
     */
    /**
     * Shows a gallery breadcrumb trail of albums
     * 
     * Parameters:
     * separator - Separator to use when outputing trail (Default: " - ". album1 - album2 - album3
     * prefix - A prefix to use when at least 1 album has been found. (Default: "")
     *          You can use this to combine this snippet with the original BreadCrumbs :-)
     * 
     * @package gallery
     */
    $gallery = $modx->getService('gallery','Gallery',$modx->getOption('gallery.core_path',null,$modx->getOption('core_path').'components/gallery/').'model/gallery/',$scriptProperties);
    if (!($gallery instanceof Gallery)) return '';
    
    $separator = $modx->getOption('separator', $scriptProperties, ' - ');
    $prefix = $modx->getOption('prefix', $scriptProperties, '');
    $returnValue = '';
    
    if (isset($_GET['galAlbum'])) {
    	$condition = true;
    	$output = array();
    	$currentAlbum = (int) $_GET['galAlbum'];
    	while($condition == true) {
    		$album = $modx->getObject('galAlbum', $currentAlbum);
    		if ($album->get('parent') != 0) {
    			$currentAlbum = $album->get('parent');
    			$output[] = $album->get('name');
    		} else {
    			$output[] = $album->get('name');
    			$condition = false;
    			break;	
    		}
    	}
    	
    	$output = array_reverse($output);
    	
    	foreach($output as $title) {
    		$returnValue .= $title.$separator;	
    	}	
    }
    
    if ($returnValue != '') {
    	$returnValue = $prefix.$returnValue;	
    }
    
    $returnValue = substr($returnValue, 0, -strlen($separator));
    
    return $returnValue;
      Follow me on twitter: @b03tz
      Follow SCHERP Ontwikkeling on twitter: @scherpontwikkel
      CodeMaster
      • 7455
      • 2,204 Posts
      Really cool should be added to the package I think, What about a GalleryWayfinder next?
        follow me on twitter: @dimmy01