Member
Member
amyg   2007-07-27, 05:43
#1
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
Member
Member
sbillard   2007-07-27, 15:47
#2
Not sure exactly what you are saying, but you might want to check out the effervescence+simpleviewer theme. It has full paging of subalbums.
Member
Member
amyg   2007-07-27, 20:49
#3
Maybe I just needed sleep - I'll try it again - I'm pretty sure I tried with the E.S theme

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.
Member
Member
sbillard   2007-07-28, 01:16
#4
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`.
Member
Member
amyg   2007-07-28, 20:05
#5
OK - I'll try to get my head around that and give it a go
thanks for getting back.
Member
Member
aitf311   2007-08-10, 03:20
#6
sbillard, I tried to use your code for ticket #2 here: http://www.zenphoto.org/trac/ticket/2 but I see now place to import
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?!
Member
Member
sbillard   2007-08-10, 21:29
#7
Here is the code you need:
`<?php

/** 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
Member
Member
amyg   2007-08-14, 18:36
#8
lovely!
Thanks again sbillard
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.