Archive view sort method

Right now in archive view looks like all the files are sorted by name. How can I change this to filemtime?

Comments

  • acrylian Administrator, Developer
    What archive view?
  • The link near the rss feed in the default theme for example, this one http://site.com/zenphoto/page/archive
    There's a list with all the months and the number of the photos uploaded.
    When I click on the month the photos are sorted by name, I would like to have them sorted by the time of the upload.
  • That view is produced by the search.php script. You would have to change the `next_image()` function to pass in the sorttype and direction. See the functions guide for detils. If you want to do this only for these date searches, you will have to make the parameters conditional on the search being that kind. (`isset($_REQUEST['date'])`)
  • Just an attempt cause I know nothing about php. I changed
    `<?php while (next_image(false, $firstPageImages)): $c++;?>`
    to
    `
    <?php
    if (isset($_REQUEST['date'])) {
    while (next_image(false, $firstPageImages, mtime, image_sortdirection)): $c++;
    } else {
    while (next_image(false, $firstPageImages)): $c++;
    }
    ?>
    `
    Of course, it's not working. Can you help a bit? Thanks. :)
  • Well, you have to pass a string for the sort type and direction so it would be `"mtime"` and `"DESC"` if you want descending otherwise just leave out the parameter.

    Plus, you can't put a part of a loop in an if statement. So our if statement should setup say `$sorttype` and `$sortdirection` Then pass these as parameters in the original loop.

    `

    `
  • Thank you! It does not appear to be working, though. The images are still sorted by name...
  • Seems that the serarch class did not implement the passing of sorttype and direction. But don't dispair. It will be there in tonight's build.
  • Thank you! Works like a charm. :)
  • Glad to help
Sign In or Register to comment.