Image Sort Order

Last post 01-25-2011, 10:58 PM by Kenneth. 5 replies.
Sort Posts: Previous Next
  •  01-21-2011, 11:27 AM 65826

    Image Sort Order

       I have everything almost 100% perfect now with the gallery. The one thing I have to accomplish is Image order. I store records in an SQL database and I create the XML file myself and populate it with data from the SQL databas (see below). There is a field in my database called ULIsPrimary. If this is Yes, I want that image to appear first. How can I accomplish this? Could I somehow populate the categoryid or properties of the XML file with Yes if ULIsPrimary is set to yes, and have the gallery sort by the categoryid or properties fields of the XML file? I just need someway to control which image appears first, short of say renaming the image with a bunch of aaaa's in front of the filename.
     
                    Dim w As System.IO.TextWriter = New System.IO.StreamWriter(directoryString + qFN1 + ".config")
                    Dim sb As New StringBuilder()
                    sb.Append("<photo name=""")
                    sb.Append("" & qFN1.Replace("&", "&amp;").Replace("'", "&apos;") & "")
                    sb.Append(""" categoryid="""" width=""")
                    sb.Append("" & Image1.Width & "")
                    sb.Append(""" height=""")
                    sb.Append("" & Image1.Height & "")
                    sb.Append(""" filesize=""")
                    sb.Append("" & qFS & "")
                    sb.Append(""" ipaddress="""" datetime="""" comment=""")
                    sb.Append("" & maxImageID & "")
                    sb.Append(""" title=""")
                    sb.Append("" & qNM.Replace("&", "&amp;").Replace("'", "&apos;") & "")
                    sb.Append(""" properties="""" />")
                    w.Write(sb.ToString())
                    w.Flush()
                    w.Close()    
                    Image1.Dispose()
     
  •  01-21-2011, 2:10 PM 65828 in reply to 65826

    Re: Image Sort Order

    Dear Regrossman,
     
     
    Thank you for asking
  •  01-22-2011, 8:23 PM 65835 in reply to 65828

    Re: Image Sort Order

    if(GalleryFormatTimeHTML(arr[j+1].Time) <GalleryFormatTimeHTML(arr[j].Time))
     
    How do I change that to look at a different field in the XML file? Or does that not look at the xml and only look at the file created date in the actual file system?
  •  01-24-2011, 2:39 AM 65844 in reply to 65835

    Re: Image Sort Order

    Hi regrossman,
     
     You can sort by the information below. But not the additional information you add.
     
    categoryid;
    photoid;
    title;
    comment;
    Width
    Height
    Size
    Time
    Url
    Thumbnail
     
     
    Regards,
     
    Ken
  •  01-24-2011, 3:44 PM 65860 in reply to 65844

    Re: Image Sort Order

    Can you show me an example of how I would sort by categoryid? In the XML file I put a number in categoryid. I replace time below with categoryid but it doesnt seem to be working...
     
      function BubbleSort(arr)
     {
            var temp;
            var exchange;
            for(var i=0; i<arr.length; i++)
            {
                exchange = false;
                for(var j=arr.length-2; j>=i; j--)
                {
                    if(GalleryFormatTimeHTML(arr[j+1].categoryid) <GalleryFormatTimeHTML(arr[j].categoryid))
                    {
                        temp = arr[j+1];
                        arr[j+1] = arr[j];
                        arr[j] = temp;
                        exchange = true;
                    }
                }
                if(!exchange) break;
            }
            return arr;
         }
        photos=BubbleSort(photos);
     
  •  01-25-2011, 10:58 PM 65884 in reply to 65860

    Re: Image Sort Order

    Hi regrossman,
     

    function BubbleSort(arr)
     {

            var temp;
            var exchange;
            for(var i=0; i<arr.length; i++)
            {
                exchange = false;
                for(var j=arr.length-2; j>=i; j--)
                {
              
                    if(arr[j+1].CategoryID <arr[j].CategoryID)
                    {
                    
                        temp = arr[j+1];
                        arr[j+1] = arr[j];
                        arr[j] = temp;
                        exchange = true;
                    }
                }
                if(!exchange) break;
            }
            return arr;
         }
     
     
    Regards,
     
    ken
View as RSS news feed in XML