By Jon Griffin

Sample

Sample -disabled for now and forever. This is DEPRECATED.

Actual Code

Thanks to Brad Duell who figured all this out and fixed many bugs.

Several procs were modified and added to paginator procs. You can download the patch file at OpenACS – Misc Patches

.tcl page

ad_page_contract {

    @author Jon Griffin jon@mayuli.com

    @creation-date 01 April 2003

    @cvs-id@ $Id$

    Sample page for ad_table/paginator integration.

} {

    {page:optional "1"}

    {orderby:optional "object_type"}

}

set p_name "sample"

set query "select

object_type,creation_date

from acs_objects a

"

# create the paginator/ad_table

request create

# paginator variables

request set_param page -datatype integer -value 1

set passthrough ""

#set orderby "object_type"

set columns {

    {object_type "Type"}

    {creation_date "Creation Date"}

}

paginator create get_objects $p_name $query -pagesize 20 -groupsize 10 -contextu

set items [ad_table get_query "$query where object_type in 

   ([paginator get_query $p_name creation_date $page])" $columns ]

paginator get_display_info $p_name info $page

set group [paginator get_group $p_name $page]

paginator get_context $p_name pages [paginator get_pages $p_name $group]

paginator get_context $p_name groups [paginator get_groups $p_name $group 10]

ad_return_template

.adp page

<master>

<!-- pagination context bar -->

<table cellpadding=4 cellspacing=0 border=0 width="95%">

<tr>

  <td align=left width="5%">

    <if @info.previous_group@ not nil>

      <a href="index?page=@info.previous_group@&@passthrough@&orderby=@orderby@"

        <<</a>    </if>

    <if @info.previous_page@ gt 0>

      <a href="index?page=@info.previous_page@&@passthrough@&orderby=@orderby@">

        <</a>

    </if>

    <else> </else>

  </td>

 <td align=center>

  <multiple name=pages>

    <if @page@ ne @pages.page@>

      <a href="index?page=@pages.page@&@passthrough@&orderby=@orderby@">@pages.p

    </if>

    <else>

      @page@

    </else>

  </multiple>

  </td>

  <td align=right width="5%">

    <if @page@ lt @info.page_count@>

      <a href="index?page=@info.next_page@&@passthrough@&orderby=@orderby@">>

    </if>

    <else> </else>

    <if @info.next_group@ not nil>

<a href="index?page=@info.next_group@&@passthrough@&orderby=@orderby@">

        >></a>

    </if>

  </td>

</tr>

</table>

@items@

Future directions

Integrated proc – ad_table should be rewritten to support pagination and made a template widget.

See the new tools::paginate page for more deprecated info.

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.