Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d7e4f03

Browse files
committed
article 新分页
1 parent 39e21ce commit d7e4f03

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/http/controller/article.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func (ArticleController) ReadList(ctx echo.Context) error {
6060
return ctx.Redirect(http.StatusSeeOther, "/articles")
6161
}
6262

63+
// 旧的分页
6364
var (
6465
hasPrev, hasNext bool
6566
prevId, nextId int
@@ -99,6 +100,13 @@ func (ArticleController) ReadList(ctx echo.Context) error {
99100
"next_id": nextId,
100101
}
101102

103+
// 新分页
104+
//curPage := goutils.MustInt(ctx.QueryParam("p"), 1)
105+
//paginator := logic.NewPaginator(curPage)
106+
//total := logic.DefaultArticle.Count(ctx, "")
107+
//pageHtml := paginator.SetTotal(total).GetPageHtml(ctx.Request().URL().Path())
108+
//pageInfo := template.HTML(pageHtml)
109+
102110
// 获取当前用户喜欢对象信息
103111
me, ok := ctx.Get("user").(*model.Me)
104112
var likeFlags map[int]int

template/articles/list.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ <h2><a href="/articles/{{.Id}}" target="_blank" title="{{.Title}}">
8383
<li class="next"><a href="/articles?lastid={{.page.next_id}}">下一页 &rarr;</a></li>
8484
{{end}}
8585
</ul>
86+
<div class="sep20"></div>
87+
{{if .page}}
88+
<div class="box_white">
89+
<div class="inner_content">
90+
<nav class="text-center"><ul class="pagination pagination-sm" style="margin: 1px 0;">{{.page}}</ul></nav>
91+
</div>
92+
</div>
93+
{{end}}
8694
</div>
8795
<div class="col-md-3 col-sm-6">
8896
<div class="sep20"></div>

0 commit comments

Comments
 (0)