Try our conversational search powered by Generative AI!

ImageQuery - Filtering Images by Tag whilst ordering by Visits.

Vote:
 

Hi all,

Im am trying to bring back an ImageCollection which is filtered by one or more Tag and ordered by the number of Visits. Currently I am attempting to use the Query system to do this. However, there does not seem to be a VisitableItemCriterion to sort the items by.

Can anyone offer some advice for the best approach to achieve this?

Many Thanks,

Martin.

 

#47367
Jan 26, 2011 16:36
Vote:
 

Hi,

Here is an example about get most viewed image, not by using Query, but it seems to be a good idea.

        /// Gets the most viewed images and binds them to the listing control
        /// </summary>
        /// <param name="page">Which page to show</param>
        private void BindMostViewedImageGalleries(int page)
        {
            int totalItems;
            // Get the most viewed images
            EntityCollection visitedItems = VisitHandler.Instance.GetVisitedItems(typeof(ImageGallery), EntityStatus.Approved, 
                page, ucImageGalleries.PageSize, Utils.CacheTimeOut.MostViewed, out totalItems, 
                new VisitableEntitySortOrder(VisitableEntitySortField.NumVisits, SortingDirection.Descending));
            ImageGalleryCollection imageGalleries = new ImageGalleryCollection();
            // Transform into an image gallery collection
            foreach (ImageGallery ig in visitedItems)
            {
                imageGalleries.Add(ig);
            }
            // Bind the image galleries
            ucImageGalleries.PageNumber = page;
            BindImageGalleries(imageGalleries, totalItems, ListingType.MostViewed);
        }
 // Get the most viewed images
            EntityCollection visitedItems = VisitHandler.Instance.GetVisitedItems(typeof(ImageGallery), EntityStatus.Approved, 
                page, ucImageGalleries.PageSize, Utils.CacheTimeOut.MostViewed, out totalItems, 
                new VisitableEntitySortOrder(VisitableEntitySortField.NumVisits, SortingDirection.Descending));

            ImageGalleryCollection imageGalleries = new ImageGalleryCollection();

            // Transform into an image gallery collection
            foreach (ImageGallery ig in visitedItems)
            {
                imageGalleries.Add(ig);
            }

Hope this could help!

Regards, Hai

 

#47737
Edited, Feb 11, 2011 4:33
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.