Has anyone worked out a way to make the 'next and previous album' work with subalbums? Right now, the links send me back to the main gallery page. thanks in advance
OK. That function does not yet support subalbums. So it is defaulting to the gallery. I took a quick look. The hack to provide subalbums is not hard, but also not trivial. You would have to make subalbum versions of `getNextAlbumURL`, `getPrevAlbumURL`, and the supporting routines: `getNextAlbum`, `getPrevAlbum`, `getAlbums` (you probably can use `getSubAlbums` for this), and `getAlbum`.
Comments
I want to use this function:
http://www.zenphoto.org/trac/wiki/DeveloperReference#getNextAlbumURLandgetPrevAlbumURL
But what happens is that instead of going to the next album - i end up back at the gallery index - or the next gallery.
I just want users to be able to go album to album, with out having to go back to the index.
thanks for getting back.
subalbumfunctions.php
I replaced my other 2 templates with yours and it doesnt break anything but I dont get to page either. Could you let me know what I am going wrong?!
`<?php<br />
/** Next and Prev SubAlbum URLs */
function getAlbumsCount() {
global $_zp_current_album;
$parentalbum = $_zp_current_album->getParent();
$id = $parentalbum->getAlbumID();
$sql = "SELECT COUNT(*) FROM ". prefix("albums") ." WHERE parentid = $id";
$result = query($sql);
$count = mysql_result($result, 0);
return $count;
}
function getNextSubalbum() {
global $_zp_current_album;
$parent = $_zp_current_album->getParent();
if (is_null($parent)) {
$result = $_zp_current_album->getNextAlbum();
if (!$result) {return null;} else {return $result;}
}
$subalbums = $parent->getSubAlbums(0);
if (($inx = $_zp_current_album->index) == null)
$inx = array_search($_zp_current_album->name, $subalbums);
$inx = $inx+1;
if ($inx >= 0 && $inx < getAlbumsCount()) {
return new Album($parent, $subalbums[$inx]);
} else {
return null;
}
}
function getPrevSubalbum() {
global $_zp_current_album;
$parent = $_zp_current_album->getParent();
if (is_null($parent)) {
$result = $_zp_current_album->getPrevAlbum();
if (!$result) {return null;} else {return $result;}
}
$subalbums = $parent->getSubAlbums(0);
if (($inx = $_zp_current_album->index) == null)
$inx = array_search($_zp_current_album->name, $subalbums);
$inx = $inx-1;
if ($inx >= 0 && $inx < getAlbumsCount()) {
return new Album($paraent, $subalbums[$inx]);
} else {
return null;
}
}
function hasPrevSubalbum() {
if (is_null(getPrevSubalbum())) {return false;}
return true;
}
function hasNextSubalbum() {
if (is_null(getNextSubalbum())) {return false;}
return true;
}
function getNextSubAlbumURL() {
if(!in_context(ZP_ALBUM)) return false;
$nextalbum = getNextSubalbum();
return rewrite_path("/" . pathurlencode($nextalbum->name),
"/index.php?album=" . urlencode($nextalbum->name));
}
function getPrevSubAlbumURL() {
if(!in_context(ZP_ALBUM)) return false;
$prevalbum = getPrevSubalbum();
return rewrite_path("/" . pathurlencode($prevalbum->name),
"/index.php?album=" . urlencode($prevalbum->name));
}
?>`
put this into your custom-functions.php
Thanks again sbillard