zenphoto forums » Usage Support

Displaying specific albums (using Zenphoto as a "plug-in")

(4 posts)
  1. LiamF1

    Junior
    Joined: Jul '09
    Posts: 6

    Hi guys,

    I'm trying to display the album tile (title, thumb, description etc.) of 3 particular albums within another page of my website outside of the zenphoto directory.

    I've viewed the help page on using Zenphoto as a "plug-in", and it seems to make sense but I can't think of what bit of code I need to specify which albums I want to appear.

    I'm using the excellent zpGalleriffic theme.

    Here is the code (modifyied a little to fit in with may website theme) on the gallery.php page which displays the album tiles:

    <?php $lastcolnum=2; setOption('albums_per_row','2',false); } else { $lastcolnum=3; setOption('albums_per_row','3',false); }?>
    			<div id="album-wrap" <?php if ( (function_exists('printLatestNews')) && ($zpgal_zp_latestnews > 0) ) { ?>class="withsidebar"<?php } ?>>
    				<ul>
    					<?php $x=1; while (next_album()): $lastcol="";
    					if ($x==$lastcolnum) {$lastcol=" class='lastcol'"; $x=0;} ?>
    					<li<?php echo $lastcol; ?>>	
    
                                <div id="port-bar" class="bar">
            <div style="height: 30px; padding-top:6px;"><a style="text-decoration:none;" href="<?php echo htmlspecialchars(getAlbumLinkURL());?>" title="<?php echo gettext('View album:').getBareAlbumTitle(); ?>"><h9 class="title2" style="margin-left:7px;"><?php echo shortenContent(getBareAlbumTitle(),30,'...'); ?></h9></a></div></div><div class="boxer">
    						<?php if (strlen(getAlbumDesc()) > 0) { ?><a class="album-thumb" href="<?php echo htmlspecialchars(getAlbumLinkURL());?>" title="<?php echo gettext('View album:'); ?> <?php echo getBareAlbumTitle();?>"><?php printCustomAlbumThumbImage(getBareAlbumTitle(),NULL,264,163,264,163); ?></a>
    						<?php } else { ?>
    						<a class="album-thumb" href="<?php echo htmlspecialchars(getAlbumLinkURL());?>" title="<?php echo gettext('View album:'); ?> <?php echo getBareAlbumTitle();?>"><?php printCustomAlbumThumbImage(getBareAlbumTitle(),NULL,238,160,238,160); ?></a>
    						<?php } ?>
    
    						<div style="padding-top:14px;"><?php if (strlen(getAlbumDesc()) > 0) { ?><div><?php echo shortenContent(getAlbumDesc(),115,'...'); ?></div><?php } ?></div>
    						<div  style="text-align:right"><small>
    							<?php printAlbumDate(); ?>
    							<?php if (getNumAlbums() > 0) { ?>&bull;&nbsp;<?php echo getNumAlbums().' '.gettext('albums'); } ?>
    							<?php if (getNumImages() > 0) { ?>&bull;&nbsp;<?php echo getNumImages().' '.gettext('images'); } ?>
    							<?php if (getCommentCount() > 0) { ?>&bull;&nbsp;<?php echo getCommentCount().' '.gettext('Comment(s)'); ?><?php } ?>
    						</small></div></div>
    					</li>
    					<?php $x++; endwhile; ?>
    				</ul>
    			</div>

    Basically, what functions do I need to include in the define code, and what piece of code do I need to choose specific albums to be displayed (eg. photography-nature, photography-urban, and photography-reflections)?

    The code all works fine in the gallery; I just need a little help in adapting it so I can use it as a plug in. Any help would be greatly appriciated!

    Posted 1 year ago #
  2. Zenphoto development team
    acrylian

    Developer
    Joined: Jul '07
    Posts: 13,364

    You need to setup the right context using the object model to use these. Recommended read:
    http://www.zenphoto.org/news/zenphotos-object-model-framework
    http://www.zenphoto.org/news/zenphotos-global-variables

    This might also be of help:
    http://www.zenphoto.org/documentation/functions/_template-functions.php.html#functionmakeAlbumCurrent

    Don't forget to read the Forum rules and usage resources
    Posted 1 year ago #
  3. LiamF1

    Junior
    Joined: Jul '09
    Posts: 6

    Thanks for those articles, I'm still learning so I hope you can have a little patience with me.

    So far I've managed to get all the album tiles to appear on my external page but haven't been able to single out the ones I want yet.

    I have inserted; `<?php
    define('WEBPATH', '../gallery');
    require_once(WEBPATH . "/zp-core/" . "template-functions.php");

    $albumobject = new Album($galleryobject,"photography-nature");
    $albumobject = new Album($galleryobject,"photography-urban");
    $albumobject = new Album($galleryobject,"photography-reflections");

    ?>`
    ...into the header of the page, but I get the following error:
    "Notice: Bad gallery in instantiation of album photography-world. in \zp-core\class-album.php on line 48"

    I tried to change getAlbumLinkURL() into $albumobject->getAlbumLinkURL() etc. too in the code I posted in the original post but that caused a fatal error.
    Obviously I'm doing something wrong but I can't figure out what.

    I can't work out how the makeAlbumCurrent fits into it either.

    I really don't want to take up any of your time but I do appriciate any guidance you can give!

    Posted 1 year ago #
  4. Zenphoto development team
    acrylian

    Developer
    Joined: Jul '07
    Posts: 13,364

    Well, you did not setup the gallery object. Please re-read and understand:
    http://www.zenphoto.org/news/zenphotos-object-model-framework

    Don't forget to read the Forum rules and usage resources
    Posted 1 year ago #

RSS feed for this topic

Reply

You must log in to post.