What determines image order of search results?

Looking at the forums it appears that the Gallery Sort should determine the sort of search returns.

This is not the behavior I get. My images are sorted by a custom sequential number in the location field within each album, but this does not seem to have any bearing on the sort either.

So when a user clicks on a Tag that returns 500 images the sort seems completely random.

Tried various custom sorts in the gallery settings, with nothing seeming to effect the search returns.

Wouldn't mind being able to set a custom sort like "date,filename" Ascending - for searches while retaining custom sort for albums.

Comments

  • You can pass sort orders to the next_xxx functions and get the order you want. Otherwise, a serch will return the items in a "relevance" order--kind of a count of how many of the search criteria match the item.
  • Don't understand how your answer corresponds with your previous posts.

    http://www.zenphoto.org/support/topic.php?id=9728

    Do I need to pass the sort order from my theme? Searching entire form for example of this concept & can't get exactly how to accomplish this.
  • It looks like it would need to be passed from this file "search.php" in zpArdoise, correct?
    `

    <?php printf(ngettext('%1$u Hit for <em>%2$s', '%1$u Hits for %2$s', $total), $total, html_encode($searchwords)); ?>

    <?php if ($total == 0 ) { ?>

    <?php echo gettext("Sorry, no matches found. Try refining your search."); ?>

    <?php } ?>





    <?php

    if (getOption('search_no_albums')) {

    if ($numimages > 0) {

    echo'
    • '; printf(gettext('Images (%s)'), $numimages); echo'
    ';

    }

    } else {

    if (getOption('search_no_images')) {

    if ($numalbums > 0) {

    echo'
    • '; printf(gettext('Albums (%s)'), $numalbums); echo'
    ';

    }

    } else {

    if ($total1 > 0) {

    echo'
    • '; printf(gettext('Albums (%1$s) & Images (%2$s)'), $numalbums, $numimages); echo'
    ';

    }

    }

    }

    ?>

    <?php if (function_exists('printSlideShowLink')) { ?>





    <?php printSlideShowLink(gettext('Slideshow')); ?>





    <?php } ?>



    <?php printPageListWithNav(' « ', ' » ', false, true, 'clearfix', NULL, true, 7); ?>



    <?php

    if (getNumAlbums() > 0) {

    include('inc_print_album_thumb.php');

    }

    if (getNumImages() > 0) {

    include('inc_print_image_thumb.php');

    }

    ?>
    `
  • acrylian Administrator, Developer
    Again, we are not familiar with third party themes. Look at the official ones' search.php and you find a next_album and next_image loop for results. You have then to find where these are in this theme, that will probably be in the files being included here which no official theme does that way (although not that bad idea to not have the same code on several theme files).
  • Thanks!!
  • wongm Member
    A check of the search.php file in the 'default' theme didn't help me.

    But the following call to next_image() will output search results in date order, with the newest items at the top.

    `next_image(false, NULL, 'date', 'desc')`

    Older versions of Zenphoto used to sort the search results in the above way - my old install of version 1.4.1.6 did just that.
  • acrylian Administrator, Developer
    Yes. But search of course is listed by relevance, depending on what fields you enabled. Look at the "related items" on our site, that is done by relevance of tags only. If you output the array you will see a specific field "weight" which determinees that (only Zenpage pages currently have none if I recall correctly)
Sign In or Register to comment.