hi guys,
i want to show the latest album only. So i can have on top of the page the latest album (styled differently than the others).
and i want to show all (or a defined number) other albums but the first one.
how is this possible? - i thought about a function <zen_albumlist limit=1 /> for the latest album and >zen_albumlist limit=5 offset=1> for the 5 latest without the one already shown with the first function.
Comments
function show_latest_album($number) {
$sql = "SELECT * FROM ". prefix("albums") ." ORDER BY id DESC LIMIT $number";
$result = mysql_query($sql);
echo '<div id="albums">';
while($r = mysql_fetch_array($result)) {
echo '<div class="album">';
if ($r['thumb']==NULL) {
$image = get_album_image($r['id']);
} else {
$image = $r['thumb'];
}
if (zp_conf('mod_rewrite') == false) {
echo '';
echo '<img src="'.WEBPATH.'/zen/i.php?a='.$r['folder'].'&i='.$image.'&s=thumb" alt="Test" />';
echo '<div class="albumdesc">';
echo '<h3>'.$r['title'].'</h3>';
} else {
echo '';
echo '<img src="'.WEBPATH.'/'.$r['folder'].'/image/thumb/'.$image.'" alt="Test" />';
echo '<div class="albumdesc">';
echo '<h3>'.$r['title'].'</h3>';
}
echo ''.$r['desc'].'';
echo '</div>';
echo '<p style="clear: both; ">';
echo '</div>';
}
echo '</div>';
}
function get_album_image($id) {
$sql = "SELECT * FROM ". prefix("images") ." WHERE albumid = $id";
$result = mysql_query($sql);
while($r = mysql_fetch_array($result)) {
return $r['filename'];
}
}
just add it to your zen/functions.php file end and then add show_latest_album($number) to your theme
What I am looking for is, on the main page, display the last 3 or 4 albums (the most recently added), and then have a main page that contains all of the galleries.
Excuse my ignorance, but is this something that would be able to use to do that sort of thing?
http://anton.gektoras.lt/zenphoto/zenphoto-latest-albums
there is a screenshot(at the bottom) of how it looks
`
function list_latest_images($number) {
$sql = "SELECT * FROM ". prefix("images") ." ORDER BY id DESC LIMIT $number";
$result = mysql_query($sql);
while($r = mysql_fetch_array($result)) {
$id=$r['albumid'];
$sql="SELECT * FROM ". prefix("albums") ." WHERE id = $id";
$album = mysql_query($sql);
$a = mysql_fetch_array($album);
echo '
echo '';
echo '';
echo '';
echo '
}
}
`
I'm new to php and sql so It's not as robust as yours but it works for me.
Hope this might help.
I've also written latest comment function and optimised latest images and albums functions.
p.s.: my server is down due to problems with Internet, so i will put every thing here
http://anton.ponadiozin.googlepages.com/
as soon as i can
currently Im using this in my index.php for listing album titles
<?php $text = getAlbumTitle(); if( strlen($text) > 22) $text = preg_replace("/[^ ]*$/", '', substr($text, 0, 22))."…"; echo$text; ?>
those album titles that are too long are shortened and a "..." is placed at the end of the title to show that it was shortened
is there a way to do the same with the above code, if you don't want longer album titles?
$text= truncate_string($text_to_limit, 100);
http://anton.ponadiozin.googlepages.com/zenphoto-latest-comments
function truncate_string2($string, $length) {
if (strlen($string) > $length) {
$short = substr($string, 0, $length);
return $short. '...';
} else {
return $string;
}
}
paste it in your functions.php file
after that replace
echo '<h3>'.$r['title'].'</h3>';
with
$title = truncate_string2($r['title'], 25);
echo '<h3>'.$title.'</h3>';
<? $number = getNumImages(); if ($number > 1) $number .= " photos"; else $number .=" photo"; echo$number; ?>
would there be a way to include this within the hack, say like if I want it next to the title within the h3 tags??
gallery_name | album_name | total_number_of_photos
???
* beyond index.php,album.php, image.php
* random image
* newest album
...
gallery_name > album_name
total_number_of_photos
Im just wondering if theres a way to show the total number of photos in a gallery as well??
but i dont think zenphoto has such function, but i will try to make small hack
just add to your title(album.php) <? $number = getNumImages(); if ($number > 1) $number .= " photos"; else $number .=" photo"; echo$number; ?> and that is all
here is an example http://lovart.gektoras.lt/stickers/
What I was asking was if there was a way to include the total number of images in an album within the hack??
function count_images($id) {
$sql = "SELECT * FROM ". prefix("images") ." WHERE albumid = $id";
$result = mysql_query($sql);
while($r = mysql_fetch_array($result)) {
$count++;
}
return $count;
}
which file in your theme do you place this:
"show_latest_album($number)"
and where in that file do you place it?
Thanks
`function count_images($id) {
$result = mysql_query("SELECT count(*) FROM ". prefix("images") ." WHERE albumid = $id");
return mysql_result($result, 1);
}`
'<?php define('ZENFOLDER', 'zp-core');
define('WEBPATH', 'pasteventsv3/');
require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php");?>
<?php echo getAlbumTitle();?><?php printAlbumTitle(); ?>'
define('WEBPATH', 'pasteventsv3/');
require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php");?>
<?php echo getAlbumTitle();?><?php printAlbumTitle(); ?>`
It is not possible to show the latest albums with the feed unless you want to do some coding. You would have to create your own feed using the image_album_statistics plugin for example.