DasBlog中的首页,类别和项目分页

We on the DasBlog still struggle with documentation (and we're always looking for folks who want to help). Any skinnable/themeable blog engine with templates and macros like DasBlog has literally hundreds of options that you can opt-in or out of.

DasBlog上,我们仍然在文档方面挣扎(并且我们一直在寻找想要帮助的人)。 带有DasBlog之类的带有模板和宏的任何可换肤/主题化的博客引擎,实际上都有数百个选项供您选择加入或退出。

DasBlog uses a macro engine with macros in the form of <% macro(param, param) %>. These macros go into two main template files (although there are others), called hometemplate.blogtemplate and itemtemplate.blogtemplate.

DasBlog使用带有<%macro(param,param)%>形式的宏的宏引擎。 这些宏进入两个主要的模板文件(尽管还有其他),分别称为hometemplate.blogtemplate和itemtemplate.blogtemplate。

The first is not just the home page, but the whole basic layout of the blog. The second is the template for any one single blog post.

第一个不仅是主页,而且是博客的整个基本布局。 第二个是任何一篇博客文章的模板。

We recently added a couple of options for paging to DasBlog, but we haven't added them to all of our 16+ default themes, and if you have a custom theme - and most of you do - then you'll note get these new features unless you add a few things to your templates.

最近,我们添加了一些用于分页到DasBlog的选项,但是我们还没有将它们添加到我们所有的16个以上默认主题中,并且如果您有自定义主题(并且大多数都这样做),那么您会注意到获得了这些功能,除非您在模板中添加了一些内容。

There's a couple different kinds of pagination, in an attempt to answer Jeff Sandquist's good question.

为了回答杰夫·桑德奎斯特的好问题,有两种不同的分页方式。

主页分页 (Home Page Paging)

image

There's "Older Posts" that you'd use to get to older ports from the home page. This takes the form of an "Older Posts" link usually at the bottom of your blog's main page, and a "Newer Posts" link if they are already off the main page. The URL will change to include a page parameter like: http://www.hanselman.com/blog/default.aspx?page=1

您可以使用“较旧的帖子”从主页访问较旧的端口。 这种形式通常是博客主页底部的“较旧帖子”链接,如果已经不在主页上,则采用“较新帖子”链接。 该URL将更改为包括如下页面参数: http : //www.hanselman.com/blog/default.aspx? page =1

All this assumes that after someone has read the first page they'll want to continue reading backward in time. You can get that by adding these macros to your hometemplate.blogtemplate:

所有这些假设是,在某人阅读了第一页之后,他们将希望继续向后阅读。 您可以通过将以下宏添加到hometemplate.blogtemplate中来实现:

<div class="post-paging">
 <div class="previous-posts">
  <% DrawPostPagingPrevious() %>
 </div>
 <div class="next-posts">
  <% DrawPostPagingNext() %>
 </div>
 <div class="clear"></div>
</div>

The divs are, of course, totally optional. These are just what I use.

div当然是完全可选的。 这些就是我用的。

类别分页 (Category Paging)

image

A lot of features are added after someone uses your product for years. I've got five years of blog posts now and I didn't have a problem with too many posts in one category in 2002, but now it's a problem. So, there's category paging, that appears only when you're on a category page and you've turned on category paging in your EditConfig.aspx.  To turn on category paging do two things, one, uncheck "Display All Entries in Category View and second, ensure there is a value in the "Entries per page" textbox.

某人使用您的产品多年后,添加了许多功能。 我现在有五年的博客文章,并且在2002年一个类别中的太多文章都没有问题,但是现在是一个问题。 因此,有一个类别页面调度,仅当您在类别页面上并且已在EditConfig.aspx中打开类别页面时才会显示。 要打开类别分页,请执行以下两项操作:第一,取消选中“在类别视图中显示所有条目”,第二,确保“每页条目数”文本框中有一个值。

image

The macro you'll need to add to your hometemplate.blogtemplate is:

您需要添加到hometemplate.blogtemplate中的宏是:

<% DrawCategoryPaging() %> 

and I usually put in in the template TWICE, once above the "bodytext" macro and once below so folks can get to the next page regardless of if they're at the top or bottom of your page.

而且我通常在TWICE模板中,将其放置在“ bodytext”宏的上方,然后将其放置在下方,以便人们可以访问下一页,无论他们位于页面的顶部还是底部。

单项分页(导航) (Single Item Paging (Navigation))

Finally, there's item paging. Not really paging, as it's navigation. It means being able to go from single post to single post. That's done by adding this to your itemtemplate.blogtemplate, usually at the top:

最后,还有项目分页。 并不是真正的分页,因为它是导航。 这意味着能够从单个帖子转到单个帖子。 可以通过将其添加到itemtemplate.blogtemplate中来完成,通常在顶部:

<%PreviousLink("&laquo;&nbsp;",40)%>
<%MainPageentryLink("Main", "|")%>
<%NextLink("&nbsp;&raquo;",40)%>

For the first and last macro, the HTML entities that are passed in are the characters that you want prepended or appended to the name of the previous and next title, and the number is the number of characters to show before truncating the title.  for the "Main" macro, the word passed in is the text to display to indicate the home page. I use the word "Main," myself. The second parameter is the separator.

对于第一个和最后一个宏,传入HTML实体是要在上一个和下一个标题的名称之前或之后加上的字符,数字是截断标题之前要显示的字符数。 对于“ Main”宏,传入的单词是要显示以指示主页的文本。 我自己使用“主要”一词。 第二个参数是分隔符。

image

Again, there's LOTS of cool stuff you can do with DasBlog that we are doing a lousy job of Documenting. If you want to get involved, join the DasBlog Developers Mailing List (Archives) and jump in. We're harmless.

再说一遍,您可以使用DasBlog做很多很酷的事情,而我们做的文档工作很糟糕。 如果您想参与其中,请加入DasBlog开发人员邮件列表(存档)并加入。我们没有害处。

翻译自: https://www.hanselman.com/blog/home-page-category-and-item-paging-in-dasblog

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值