I know this probably has been asked already somewhere, but I don't seem to find it... (And with the wiki still being down...) Anyway. I would like to list all albums on my image.php page (as text links). How can I do this? I was doing a simple copy/paste code method from the index.php, but it doesn't seem to be working. Any suggestions?
Thx.
I have exactly the same question. I am using a dropdown jump menu for quick links nav menu which is outputted on every page(image.php, index.php and albums.php).
Since updating to latest version 1.0.6 it only outputs the info on index.php.
Anyone tell me whats happened and how to fix it?
I am currently using the following code to print the relevant info which was working perfectly before:
Okay found it.
In the file "template-functions.php" (in the "zen" directory) you can find a function called "next_album" (somewhere around line 311).
The comments say: "If we're already in the album context, this is a sub-albums loop, which, quite simply, changes the source of the album list." So we need to change this again.
Change this part of the code:
if (in_context(ZP_ALBUM)) {
$_zp_albums = $_zp_current_album->getSubAlbums();
} else {
$_zp_albums = $_zp_gallery->getAlbums($_zp_page);
}
To this:
if (in_context(ZP_ALBUM)) {
//$_zp_albums = $_zp_current_album->getSubAlbums();
$_zp_albums = $_zp_gallery->getAlbums($_zp_page);
} else {
$_zp_albums = $_zp_gallery->getAlbums($_zp_page);
}
DANGER: That change disables sub-albums.
If you want to loop the root albums, just set the context before calling the function:
`set_context(ZP_INDEX);
while (next_album()):
...
endwhile;
set_context(ZP_ALBUM);`
In the future maybe I'll make this an option of the next_album() function, something like next_album($level=0) for the root, next_album($level=-1) for the current level...
I too am looking to list sub-albums in image.php...but havent had any luck...
I have no trouble listing parent albums in image.php with this code:
`
`
According to trisweb above, this should work to list subalbums in image.php
`
`
But nothing appears--there should be a bunch of subalbums listed.. printAlbumTitle() alone, out of the while loop, manages to print the current subalbum title but i cant get the other subalbums to list.
This doesnt work either.
`
`
It would be great if anyone could point me in the right direction on this. Thanks!
I too am trying to list in image.php the subalbums of the image's immediate parent album. Not having much like, like protum.
Here's an example:
AlbumB contains SubAlbum1, SubAlbum2, SubAlbum3.
I'm viewing Image5 in SubAlbum3.
I'm trying to make Image5's page show a dropdown menu that lists/links to SubAlbum1, SubAlbum2, SubAlbum3.
Take a look at the function print_album_menu.php that is located in the zp-core/plugins folder of your zenphoto installations. Move the file to your theme's folder and call it in the head with require_once('print_album_menu.php').
That does exactly what you want and works on index, album and image.php and has an option for a drop down menu. How to use it is included in the file as comments.
One drawback: The menu supports currently only one subalbum level. It will be expanded to support to all levels, but that may take a little time.
teedog:
I just rediscovered that I once made a function that lists subalbums when you are it's parent album, one of the subalbum or in an image of them. It's more a draft and unfortunatly only supports one subalbum level too (it was made for 1.0.8.2). But maybe it fits your needs, take a look:
`
$option = "count" for image counter behind the subalbum name, "" for no image counter
The parameters are optional if you want specify CSS-IDs to style the menu. You can leave them blank, too.
$id1 = Insert here the ID for the main album menu like this.
$active1 = Insert the ID for the currently active album link
*/
function printSubAlbumMenu($option,$id1,$active1) {
if ($id1 != "") { $id1 = " id='".$id1."'"; }
if ($active1 != "") { $active1 = " id='".$active1."'"; }
// main album query
$sql = "SELECT id, parentid, folder, title FROM ". prefix('albums') ." WHERE parentid is NULL ORDER BY sort_order";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$number++;
$idnr[$number] = $row['id'];
$parentid[$number] = $row['parentid'];
$folder[$number] = $row['folder'];
$title[$number] = $row['title'];
switch($option) {
case "count":
// count images in the main albums
$sql = "SELECT COUNT(id) FROM ". prefix('images') ." WHERE albumid = $idnr[$number]";
$result2 = query($sql);
$count = mysql_result($result2, 0);
$imagecount[$number] = " (".$count.")";
}
}
// sub album query - possibly these two queries could be done better...
$sql = "SELECT id, parentid, folder, title FROM ". prefix('albums') ." WHERE parentid ORDER BY sort_order";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$subnumber++;
$subidnr[$subnumber] = $row['id'];
$subparentid[$subnumber] = $row['parentid'];
$subfolder[$subnumber] = $row['folder'];
$subtitle[$subnumber] = $row['title'];
switch($option) {
case "count":
// count images in the subalbums
$sql = "SELECT COUNT(id) FROM ". prefix('images') ." WHERE albumid = $subidnr[$subnumber]";
$result2 = query($sql);
$count2 = mysql_result($result2, 0);
$subimagecount[$subnumber] = " (".$count2.")";
}
}
// album view: list subalbums in this album
for ($nr = 1;$nr
Your function uses "getIDForAlbum", I think this has to be getAlbumId. Anyways, great function! Exactly what i'm looking for here: http://www.zenphoto.org/support/topic.php?id=1883&replies=7