0b3763cc by Jens Bissinger

Cleanup pagination documentation. Refs #835.

1 parent fa6cbc08
...@@ -12,55 +12,6 @@ ...@@ -12,55 +12,6 @@
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 // Usage
16 //
17 // In your beego.Controller:
18 //
19 // package controllers
20 //
21 // import "github.com/astaxie/beego/utils/pagination"
22 //
23 // type PostsController struct {
24 // beego.Controller
25 // }
26 //
27 // func (this *PostsController) ListAllPosts() {
28 // // sets this.Data["paginator"] with the current offset (from the url query param)
29 // postsPerPage := 20
30 // paginator := pagination.SetPaginator(this, postsPerPage, CountPosts())
31 //
32 // // fetch the next 20 posts
33 // this.Data["posts"] = ListPostsByOffsetAndLimit(paginator.Offset(), postsPerPage)
34 // }
35 //
36 //
37 // In your view templates:
38 //
39 // {{if .paginator.HasPages}}
40 // <ul class="pagination pagination">
41 // {{if .paginator.HasPrev}}
42 // <li><a href="{{.paginator.PageLinkFirst}}">{{ i18n .Lang "paginator.first_page"}}</a></li>
43 // <li><a href="{{.paginator.PageLinkPrev}}">&laquo;</a></li>
44 // {{else}}
45 // <li class="disabled"><a>{{ i18n .Lang "paginator.first_page"}}</a></li>
46 // <li class="disabled"><a>&laquo;</a></li>
47 // {{end}}
48 // {{range $index, $page := .paginator.Pages}}
49 // <li{{if $.paginator.IsActive .}} class="active"{{end}}>
50 // <a href="{{$.paginator.PageLink $page}}">{{$page}}</a>
51 // </li>
52 // {{end}}
53 // {{if .paginator.HasNext}}
54 // <li><a href="{{.paginator.PageLinkNext}}">&raquo;</a></li>
55 // <li><a href="{{.paginator.PageLinkLast}}">{{ i18n .Lang "paginator.last_page"}}</a></li>
56 // {{else}}
57 // <li class="disabled"><a>&raquo;</a></li>
58 // <li class="disabled"><a>{{ i18n .Lang "paginator.last_page"}}</a></li>
59 // {{end}}
60 // </ul>
61 // {{end}}
62 //
63 // See also http://beego.me/docs/mvc/view/page.md
64 package pagination 15 package pagination
65 16
66 import ( 17 import (
......
1 /*
2
3 The pagination package provides utilities to setup a paginator within the
4 context of a http request.
5
6 Usage
7
8 In your beego.Controller:
9
10 package controllers
11
12 import "github.com/astaxie/beego/utils/pagination"
13
14 type PostsController struct {
15 beego.Controller
16 }
17
18 func (this *PostsController) ListAllPosts() {
19 // sets this.Data["paginator"] with the current offset (from the url query param)
20 postsPerPage := 20
21 paginator := pagination.SetPaginator(this, postsPerPage, CountPosts())
22
23 // fetch the next 20 posts
24 this.Data["posts"] = ListPostsByOffsetAndLimit(paginator.Offset(), postsPerPage)
25 }
26
27
28 In your view templates:
29
30 {{if .paginator.HasPages}}
31 <ul class="pagination pagination">
32 {{if .paginator.HasPrev}}
33 <li><a href="{{.paginator.PageLinkFirst}}">{{ i18n .Lang "paginator.first_page"}}</a></li>
34 <li><a href="{{.paginator.PageLinkPrev}}">&laquo;</a></li>
35 {{else}}
36 <li class="disabled"><a>{{ i18n .Lang "paginator.first_page"}}</a></li>
37 <li class="disabled"><a>&laquo;</a></li>
38 {{end}}
39 {{range $index, $page := .paginator.Pages}}
40 <li{{if $.paginator.IsActive .}} class="active"{{end}}>
41 <a href="{{$.paginator.PageLink $page}}">{{$page}}</a>
42 </li>
43 {{end}}
44 {{if .paginator.HasNext}}
45 <li><a href="{{.paginator.PageLinkNext}}">&raquo;</a></li>
46 <li><a href="{{.paginator.PageLinkLast}}">{{ i18n .Lang "paginator.last_page"}}</a></li>
47 {{else}}
48 <li class="disabled"><a>&raquo;</a></li>
49 <li class="disabled"><a>{{ i18n .Lang "paginator.last_page"}}</a></li>
50 {{end}}
51 </ul>
52 {{end}}
53
54 See also
55
56 http://beego.me/docs/mvc/view/page.md
57
58 */
59 package pagination
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!