Results 1 to 5 of 5

Thread: Virtual Pagination script (demo 4)

  1. #1
    Join Date
    Feb 2008
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Virtual Pagination script (demo 4)

    Title: Virtual Pagination script (demo 4)
    http://www.dynamicdrive.com/dynamici...pagination.htm

    Question:
    I've used demo 4 on this page to setup an event calendar of sorts (in lieu of finding one specifically for that purpose). On the virt. page script, it defaults to the first or leftmost "page." In the example below, I am breaking up the pages as "Jan-Feb" "Mar-Apr" etc...

    example link here

    My question is, could the systems date cause the current month to be the default first page. Reason being, it somewhat de-values an event calendar if it's say, July and the default page is always January.

    Alternatively, if anyone knows of another tool to fulfill this purpose let me know.

    Thanks,
    Steve

  2. #2
    Join Date
    Feb 2006
    Posts
    236
    Thanks
    8
    Thanked 3 Times in 3 Posts

    Default

    Yes, you can do that with the instance.showpage(page_number) function. You need to write a java script function that is called when the page is loaded, the onload. The function would determine the month number, then change the variable to have 6 values, 0 through 5, and that is the variable to put in the showpage call that happens at onload.

    BTW, the fix that I submitted months ago still hasn't been added to the code, I see. Without it, the item selected through the instance.showpage will not be highlighted correctly as it should be.

  3. The Following User Says Thank You to Strangeplant For This Useful Post:

    strat68 (07-03-2008)

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

    Default

    Sure. The key is to use the supported function:

    instance.showpage(page_number)

    to directly go to a specific page within your Virtual Pages (see docs). In your case, following your initialization code, you'd add the part in red to it:

    Code:
    <script type="text/javascript">
    var gallery=new virtualpaginate("virtualpage4", 1)
    gallery.buildpagination("galleryalt", ["Jan-Feb", "Mar-Apr", "May-Jun", "Jul-Aug", "Sep-Oct", "Nov-Dec"])
    var currentmonth=new Date().getMonth()+1 //get current month: 1-12
    var currentmonthrange=Math.round(currentmonth/2)
    gallery.showpage(currentmonthrange-1)
    </script>

  5. The Following User Says Thank You to ddadmin For This Useful Post:

    strat68 (07-03-2008)

  6. #4
    Join Date
    Feb 2008
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Strangeplant View Post
    BTW, the fix that I submitted months ago still hasn't been added to the code, I see. Without it, the item selected through the instance.showpage will not be highlighted correctly as it should be.
    Hi Strangeplant, can I get the fix directly for now?

    Thanks,
    Steve

  7. #5
    Join Date
    Feb 2006
    Posts
    236
    Thanks
    8
    Thanked 3 Times in 3 Posts

    Default

    Sure, sorry that I haven't responded sooner (maybe this is too late), been busy and not on this board.

    Just find the same section in the virtual pagination script, the one at: http://dynamicdrive.com/dynamicindex...ualpaginate.js, and fix it like this (additions are in red):
    Code:
    // -------------------------------------------------------------------
    // PUBLIC: showpage(pagenumber)- Shows a page based on parameter passed (0=page1, 1=page2 etc)
    // -------------------------------------------------------------------
    
    virtualpaginate.prototype.showpage=function(pagenumber){
    var totalitems=this.pieces.length //total number of broken up divs
    var showstartindex=pagenumber*this.chunksize //array index of div to start showing per pagenumber setting
    var showendindex=showstartindex+this.chunksize-1 //array index of div to stop showing after per pagenumber setting
    if (this.flatviewpresent)
    this.flatviewlinks[this.currentpage].className="" //"Unhighlight" previous page (before this.currentpage increments)
    for (var i=0; i<totalitems; i++){
    if (i>=showstartindex && i<=showendindex)
    this.pieces[i].style.display="block"
    else
    this.pieces[i].style.display="none"
    }
    this.currentpage=parseInt(pagenumber)
    if (this.cpspan) //if <span class="paginateinfo> element is present, update it with the most current info (ie: Page 3/4)
    this.cpspan.innerHTML='Page '+(this.currentpage+1)+'/'+this.pagecount
    
    if (this.flatviewpresent)
    this.flatviewlinks[this.currentpage].className="selected" //"Highlight" current page
    }

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
  •