Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Ajax Pagination script v1.2.2 - make a to z?

  1. #1
    Join Date
    Mar 2008
    Posts
    19
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Ajax Pagination script v1.2.2 - make a to z?

    1) Script Title: Ajax Pagination script v1.2.2

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...nate/index.htm

    3) Describe problem: How to make links A to Z instad of 1,2,3, etc

    Hi,

    I am looking for a pagination script to list pages as A to Z (whole alphabet showing), with inactive letters for pages with no content.

    Most pagination scripts keep all the info on one page so I like the way that this one dynamically links to a separate page, loading it only when needed. Is there some way this script can be modified for an a-z listing? I think that it is important that unused letters are shown as inactive rather than not showing at all, as it keeps thing nice and tidy.

    Any suggestion? Please be gentle with me - javascript isn't my forte!

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Try adding the below line in red to the .js file:

    Code:
    ajaxpageclass.ellipse="..." // Ellipse text (no HTML allowed)
    ajaxpageclass.alpha="abcdefghijklmnopqrstuvwxyz".split('')
    Then find the chunk of code:

    Code:
    			for (var i=0; i<this.pageinfo.pages.length; i++){
    				var ellipses={left: (i==0? this.ellipse : ''), right: (i==this.pageinfo.pages.length-1? this.ellipse : '')} //if this is 1st or last page link, add ellipse next to them, hidden by default
    				paginateHTML+='<li>'+ellipses.right+'<a href="#page'+(i+1)+'" rel="'+i+'" '+this.pagerangestyle+'>'+(i+1)+'</a>'+ellipses.left+'</li>\n'
    			}
    and replace that with:

    Code:
    			for (var i=0; i<this.pageinfo.pages.length; i++){
    				var ellipses={left: (i==0? this.ellipse : ''), right: (i==this.pageinfo.pages.length-1? this.ellipse : '')} //if this is 1st or last page link, add ellipse next to them, hidden by default
    				paginateHTML+='<li>'+ellipses.right+'<a href="#page'+(i+1)+'" rel="'+i+'" '+this.pagerangestyle+'>'+ajaxpageclass.alpha[i]+'</a>'+ellipses.left+'</li>\n'
    			}
    			for (var i=this.pageinfo.pages.length; i<26; i++){
    				paginateHTML+='<li>'+ellipses.right+'<a href="#page'+(i+1)+'" class="disabled" rel="'+i+'" '+this.pagerangestyle+'>'+ajaxpageclass.alpha[i]+'</a>'+ellipses.left+'</li>\n'
    			}
    Edit: Fixed error
    Last edited by ddadmin; 12-06-2008 at 08:39 PM.
    DD Admin

  3. #3
    Join Date
    Mar 2008
    Posts
    19
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the prompt reply - I will try that out and let you know how it goes.

  4. #4
    Join Date
    Mar 2008
    Posts
    19
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    I have tried out the script change with the demo file. The links now say "undefined" instead of the letter - is there something else I need to do?

  5. #5
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Nope, the above changes should work as is. Here is the modified .js file in case you made a mistake.

    Edit: Fixed error
    Last edited by ddadmin; 12-06-2008 at 08:40 PM.
    DD Admin

  6. #6
    Join Date
    Mar 2008
    Posts
    19
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    I downloaded the js file you attached and tried that, but still got the same problem. I then thought it might be a browser issue and found that it works in Firefox and Opera, but not IE 7 which is what I was testing it in. In IE7, I just get 'undefined' instead of letters.

    Another issue is that even though other letters are shown as inactive links if there are not 26 files, they do not correspond to the actual letter. For example, if I have only pages for a, b, c and m, then instead of links showing just for a, b, c and m, they show as a, b,c and d, with d linking to m (if that makes sense!). I suppose to do that correctly, the generated links would have to somehow be linked to the name of the file (I would just be calling them a.html, b.html.....)

  7. #7
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Ops, forgot to test it in IE. I've corrected the error in the inline code and attached .js file.

    Another issue is that even though other letters are shown as inactive links if there are not 26 files, they do not correspond to the actual letter
    Hmm that could be tricky. You need a generic way to determine which page should match up with which letter, so the script could tap into that method when generating the pagination links. For example, are your pages named "a.htm", "b.htm", etc that can be easily identified as being a particular page?
    DD Admin

  8. #8
    Join Date
    Mar 2008
    Posts
    19
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the edited file - it works fine in IE now. Yes, I would be just naming the files a.html, b.html, etc I would probably also be putting them in their own directory.

    Thank you so much for all your help so far - it is really appreciated

  9. #9
    Join Date
    Mar 2008
    Posts
    19
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Hi - any ideas?

  10. #10
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Sorry for the delay. Ok, try the below .js file. It still outputs all 26 alphabet letters as pagination links, but which one is linked depends on which files are set to be shown based on the syntax alphabet+".html". For example:
    Code:
    var bookonflowers={
    pages: ["a.html", "e.html", "d.html", "z.html"],
    selectedpage: 0 //set page shown by default (0=1st page)
    }
    Would cause the corresponding 5 links in the pagination links to be hyperlinked as a result, using this .js file.
    DD Admin

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •