Pages (2): 1 2   
Member
Member
dendraya   07-05-2006, 13:18
#1

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 for the latest album and >zen_albumlist limit=5 offset=1> for the 5 latest without the one already shown with the first function.

Member
Member
Jasper   25-07-2006, 17:33
#2

This would be superexcellent! A feature I'm currently missing on my homepage...

Member
Member
antoxa   26-07-2006, 17:19
#3

here it is
function show_latest_album($number) {
$sql = "SELECT * FROM ". prefix("albums") ." ORDER BY id DESC LIMIT $number";
$result = mysql_query($sql);

echo '';
while($r = mysql_fetch_array($result)) {
    echo '';

    if ($r['thumb']==NULL) {
        $image = get_album_image($r['id']);
    } else {
        $image = $r['thumb'];
    }

    if (zp_conf('mod_rewrite') == false) {
        echo '.']';
        echo '';
        echo '';
        echo '.']'.$r['title'].'';
    } else {
        echo '.']';
        echo '';
        echo '';
        echo '.']'.$r['title'].'';
    }
    echo ''.$r['desc'].'';
    echo '';
    echo '';
    echo '';
}
echo '';

}

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

Member
Member
CJ92   02-08-2006, 02:33
#4

Hi, I really want to use this script, unfortunately I have no idea how.

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?

Member
Member
antoxa   05-08-2006, 12:08
#5

yes.
http://anton.gektoras.lt/zenphoto/zenphoto-latest-albums
there is a screenshot(at the bottom) of how it looks

Unregistered
Unregistered
Guest   10-08-2006, 15:52
#6

thanks for that function antoxa. I was looking for a 'list latest images' function like this. here's what I've come up with:
`

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 '[img]'.WEBPATH.'/zen/i.php?a='.$a['folder'].'&i='.$r['filename'].'&s=thumb[/img]';

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.

Member
Member
antoxa   14-08-2006, 09:42
#7

I've already posted latest images function in this forum, so use search
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

Member
Member
roraz   15-08-2006, 01:36
#8

Is there a way to change the latest albums code above so you can limit the characters in the albums title (if too long)??

currently Im using this in my index.php for listing album titles

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?

Member
Member
antoxa   15-08-2006, 08:21
#9

to roraz: there is a zenphoto function truncate_string
$text= truncate_string($text_to_limit, 100);

Member
Member
antoxa   15-08-2006, 08:55
#10

here is my(taken from zenphoto admin :] ) latest comments function
http://anton.ponadiozin.googlepages.com/zenphoto-latest-comments

Member
Member
roraz   15-08-2006, 17:53
#11

antoxa, how would i employ that in your latest album code, to get a short album title? My knowledge of php is practically non existent ??!

Member
Member
antoxa   16-08-2006, 07:49
#12

i was wrong about truncate_string it doesn't work correctly here how it should look:

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 ''.$r['title'].'';
with
$title = truncate_string2($r['title'], 25);
echo ''.$title.'';

Member
Member
roraz   16-08-2006, 17:05
#13

I have this tag for showing a galleries total number of photos:

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??

Member
Member
antoxa   21-08-2006, 13:50
#14

you want your title to look like this
gallery_name | album_name | total_number_of_photos
???

Member
Member
edasque   21-08-2006, 14:17
#15

is this all going in the wiki ? There has been a lot of useful scripts recently that should be archived there:

  • beyond index.php,album.php, image.php
  • random image
  • newest album
    ...
Member
Member
antoxa   21-08-2006, 18:49
#16

i will try to add all my hacks there

Member
Member
roraz   23-08-2006, 01:38
#17

it could look like this

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??

=)

Member
Member
antoxa   23-08-2006, 18:08
#18

of course there is =)
but i dont think zenphoto has such function, but i will try to make small hack =)

Member
Member
antoxa   23-08-2006, 18:32
#19

sorry i mixed up a bit =)
just add to your title(album.php) and that is all
here is an example http://lovart.gektoras.lt/stickers/

Member
Member
roraz   24-08-2006, 03:52
#20

isn't that what I posted a few posts above??

What I was asking was if there was a way to include the total number of images in an album within the hack??

=)

Pages (2): 1 2   
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.