most recent images

Is there a way of displaying the most recent images on the index page?

Thanks
Scott

Comments

  • Has anyone details of this post as the link appears to be broken?

    I really need a way to display recent images.
  • `<?<br />
    $recent = query_full_array("SELECT i.id AS imageid, i.title, i.filename, a.place, a.date AS adate, a.folder, a.title AS albumtitle FROM ".prefix('images')." AS i, ".prefix('albums')." AS a " . "WHERE i.albumid = a.id ORDER BY i.id DESC LIMIT 10");

    foreach ($recent as $rec) {

    $album = $rec['folder'];

    $place = $rec['place'];

    $adate = $rec['adate'];

    $image = $rec['filename'];

    $thumb = $rec['folder'] . "_" . $rec['filename'] . "_thumb.jpg";

    $albumtitle = $rec['albumtitle'];

    echo "image

    $albumtitle

    n";

    }

    ?>`

    this should work, I hope..
  • It work only with mod rewrite enabled. And ZP version 1.0.2 for sure, don't know if in 1.0.3 too
  • Thanks for the reply koffe.

    I am using 1.0.3 and it works to a point. It seems that in 1.0.3 they changed the naming of the thumbs so they no longer are 'filesnames_thumb.jpg' but the filesname and then some dimensions.

    e.g.

    filename.jpg_100_cw85_ch85.jpg
    filename.jpg_119_w119_cw119_ch96.jpg
    filename.jpg_595.jpg

    Any thoughts? Your help would be appreciated.
  • bbish007-

    I have a function that seems to work well for me. You can see it in operation Here.

    /* Show Latest Images */

    `function show_latest_images($number) {

    $iw = $cw = zp_conf('thumb_crop_width');

    $ih = $ch = zp_conf('thumb_crop_height');

    $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 ''.$r['title'].'';

    // echo 'Test';

    echo '
    ';

    echo '

    ';

    }

    }```
  • `/* Show Latest Images */

    function show_latest_images($number) {

    $iw = $cw = zp_conf('thumb_crop_width');

    $ih = $ch = zp_conf('thumb_crop_height');

    $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 ''.$r['title'].'';

    // echo 'Test';

    echo '
    ';

    echo '

    ';

    }

    }`````
  • Sorry if the code got mangled. If it doesn't seem to come through right for you, let me know at craig (at) thinkdreams.com and I can email it to you.
  • Thats great, thanks Craig..... just what I was looking for.
  • Hello Thinkdreams, kofee and bbish.

    This is just a suggestion.

    Since this function could make the home page more like a photoblog, which is a relatively widespread use of galleries, could it be inserted in the default theme available with a theme option? ("show last photos in the home page" and "how many photos to show in the home page?").

    Should I post this in the Trac wiki to see if it is a popular desire?

    Best regards...
  • acrylian Administrator, Developer
    That function is already a template function (this thread is a little old). You can do that simply by yourself. Just add `<?php printLatestImages(<number-of-images-you-want-here); ?>` on your index.php where you want them to be shown.

    Please take a look at our functions guide in the user guide section of our site, too.
  • Hello Acrylian.

    Thanks a lot for your precise help. I have managed to find where to put it, and it works great. :-)

    However, I have no php or coding knowledge, and I don't know how to read/use the functions guide to create the paging (previous/next) links.

    If I manage to do it, which is the right place to document this how-to? The trac wiki?

    Thanks a lot and best regards...

    --
    EM
  • acrylian Administrator, Developer
    The trac wiki is more or less a place for users to add things, all important stuff is on the normal site. Regarding the pagelist the best would be you look at one of the standard themes how it's done there.

    The functions guide not that hard to read actually, you just need to get into it once. Example:
    `printPageListWithNav( string $prevtext, string $nexttext, [bool $oneImagePage = false], [string $nextprev = true], [string $class = 'pagelist'], [string $id = NULL] )`
    All that options next to the function are describe above it. "string" means there is text to be added for example.
  • Thanks Acrylian.

    After some trial and error, I could understand the syntax. However, it still doesn't print the page navigator (take a look @ http://eduardo.mercovich.net/fotos/ if you like).

    This is the code I inserted in the index.php:
    `

    Útimas fotos...

    <?php printLatestImages(50); ?>

    <?php printPageListWithNav(previa, siguiente, $oneImagePage = false, $nextprev = true, $class = 'pagelist'); ?>

    `

    The latest 50 images are shown, but I have 77, so at least there should be a link with "siguiente".

    What am I doing wrong?

    Thanks a lot... :-)

    PS: maybe a hint... in the markup, the class is pagelist disabled_nav. Why?
    --
    EM
  • acrylian Administrator, Developer
    Re: pageslist
    <?php printPageListWithNav(previa, siguiente, $oneImagePage = false, $nextprev = true, $class = 'pagelist'); ?>`
    That can't work. It should be;
    <?php printPageListWithNav("previa", "siguiente", false, true, 'pagelist'); ?>

    Re: latest images
    The latest images function shows only the number of latest images and is working as it's meant. There is no next button supposed to be. Its not meant to show all images you have like on a photoblog and the pagelist is for the list of albums. You see how zenphoto works if you try a standard theme. The structure is Album index -> Thumbs -> Bigger Pictures. You probably want to use zenphoto as a photoblog?
  • Hi Acrylian.

    `<?php printPageListWithNav("previa", "siguiente", false, true, 'pagelist'); ?>`

    Ah, sorry, I had a syntax problem...

    Regarding ZP use, I want to use it as it is *and* with a navigable list, as a photoblog.

    However, I believe there is a workaround... :-)

    I am using 1 album ("Todas") with all the photos. The rest are dynamic albums except one specific album that has a password, since it is for the family only.

    I can make in the home page a list of the album "todas" that has pagination, and has all the photos except the ones in the family album (that don't have to be listed in the first page).

    Now, with your keyword "photoblog" (seems stupid but I didn't thought about that one, my fault) I searched and found a few posts regarding it, and the sigle physical album with N dynamic albums solution seems to have even more sense.

    I believe that would work perfectly for me (and for others, I hope). :-)

    Best regards...
  • acrylian Administrator, Developer
    Ok, I see, it is of course possible to build a theme to use zp as a photoblog. If I recall right there has been an theme for that before I became developer, but that is now not compatible anymore.
    Let us know if you manage it!
  • Hello,

    I want to use the function <?php printLatestImages(); ?> in another page of my website (not on the index of my portfolio).
    What must I do ? Code ?

    I am a novice, sorry...

    Now, an error sentence is appearing : "Fatal error: Call to undefined function: printlatestimages() in /home.10.16/boutsdep/www/portfolio/8photos.php on line 55"

    Thanks a lot in advance for your help.

    Vincent
  • acrylian Administrator, Developer
    I presume you mean a not-zenphoto-page: http://www.zenphoto.org/2008/01/hacks/#zenphoto-as-plugin
  • Yes !!

    It's ok thanks.
    But it possible to customize the thumbs organisation ?

    Thanks for your help.

    Vincent
  • acrylian Administrator, Developer
    Use a div and CSS to make it show either as a column or as a row.

    PS: Nice site by the way. Be sure to submit it to our showcase if you haven't already (lost overview...:-))
  • Ok, I'll try that tomorrow ;)

    I'm looking for submitting it to your showcase.
    Thanks again for your help, and for the work you're doing on ZenPhoto for us...

    Vincent
  • Hello, I didn't succed...

    But : I want to show the last shots taken --> Last photos organized by date (the most recent first). And not the lasts photo updated...

    How can I do that ?
  • Yes but I want to get the latest images (by date) of the entire gallery, and not in a specific album.

    And I don't have the "image_album_statistics.php" file...

    I'm sorry again, I'm a "PHP" novice, and I'm french, so my english is not really good.

    Vincent
  • acrylian Administrator, Developer
    Well, if you don't have that file, you probably should update to 1.1.6. That function gets the latest images of the gallery, the specific album is optional.
  • Is printLatestImages still in template-fuctions.php ? I can't find it.
  • How to load this function out of Zenphoto since it resides inside a plugin file now and when I try to read it, it shows this error:

    'Fatal error: Call to undefined function zp_loggedin() in /home/navjot/public_html/geneliaonline.in/gallery/zp-core/plugins/image_album_statistics.php on line 305'

    Please help.
  • acrylian Administrator, Developer
    It is in a plugin from the beginning actually...

    What are you doing actually? If calling it outside Zenphoto you have to do this: http://www.zenphoto.org/2008/01/hacks/#zenphoto-as-plugin
Sign In or Register to comment.