# 更改视图以创建日期？

**URL:** https://meta.discourse.org/t/changing-views-to-creating-date/253460
**Category:** UX
**Created:** [2023年一月31日 07:44 UTC](https://meta.discourse.org/t/changing-views-to-creating-date/253460 "2023-01-31T07:44:59Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [2023年一月31日 07:44 UTC](https://meta.discourse.org/t/changing-views-to-creating-date/253460/1 "2023-01-31T07:44:59Z")

</div>

`/latest`（以及其他所有内容）看起来是这样的：

 ![image](https://global.discourse-cdn.com/meta/original/4X/4/3/a/43a7aa9af4374bb5f7238f480e7c4e7b54999c71.jpeg)

_Replies_（回复数）显示了一个主题有多活跃，_Activity_（活动时间）显示了上次发生变化的时间。这些都是有用的数据。但 _Views_（浏览量）……它对管理员和 OP（原帖发帖人）来说可能是一个有价值的指标，但对普通用户来说却毫无价值——他们不会看一眼然后想“嗯，这个话题肯定不有趣，因为很少有人打开过它”（反之亦然）。

但如果我们能看到创建/开始日期，就能立即知道一个主题是古老的还是全新的。

我之所以截取这张截图，是因为我回复了那个主题。如果我知道那是一个相当古老的主题，我可能会置之不理——所以，对于讨论来说，显示日期可能是一把双刃剑，我知道。

我猜想这可以通过一个主题组件来改变。但这有多难呢？

我说“难”的意思是……有没有人愿意免费做这件事？我不会编程。我是复制粘贴博士，仅此而已。而且我绝对没有预算。

但我也很想知道，是否只有我一个人认为显示浏览量主要是为了满足管理员的好奇心（例如，我们可以通过 SQL 获取日志和浏览量），以及填补空白空间，所以我们可以用同样的空间做更有成效的事情？

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [2023年三月25日 00:57 UTC](https://meta.discourse.org/t/changing-views-to-creating-date/253460/2 "2023-03-25T00:57:21Z")

</div>

你好 Jakke,

不确定你是否还需要这个，但这是你要找的！  
你可以通过覆盖相关的模板来替换“views”列（[topic-list-header](https://github.com/discourse/discourse/blob/main/app/assets/javascripts/discourse/app/templates/topic-list-header.hbr) 和 [topic-list-item](https://github.com/discourse/discourse/blob/main/app/assets/javascripts/discourse/app/templates/list/topic-list-item.hbr)）。

不幸的是，它有一个缺点，就是你必须复制粘贴大量的原始代码，这可能会根据你的主题/插件/组件而无法正常工作。另外，如果 Discourse 更新了这些部分，你可能也需要更新它。

这是你可以复制粘贴到 [component](https://meta.discourse.org/t/beginners-guide-to-using-discourse-themes/91966#create-new-themes-and-theme-components-7) 中的代码：

> **Head**
>
> ```js
> 
> <script type='text/x-handlebars' data-template-name='topic-list-header.raw'>
> {{raw-plugin-outlet name="topic-list-header-before"}}
> {{#if bulkSelectEnabled}}
> <th class="bulk-select topic-list-data">
> {{#if canBulkSelect}}
> {{raw "flat-button" class="bulk-select" icon="list" title="topics.bulk.toggle"}}
> {{/if}}
> </th>
> {{/if}}
> {{raw "topic-list-header-column" order='default' name=listTitle bulkSelectEnabled=bulkSelectEnabled showBulkToggle=toggleInTitle canBulkSelect=canBulkSelect canDoBulkActions=canDoBulkActions}}
> {{raw-plugin-outlet name="topic-list-header-after-main-link"}}
> {{#if showPosters}}
> {{raw "topic-list-header-column" order='posters' ariaLabel=(i18n "category.sort_options.posters")}}
> {{/if}}
> {{raw "topic-list-header-column" sortable=sortable number='true' order='posts' name='replies' ariaLabel=(i18n "sr_replies")}}
> {{#if showLikes}}
> {{raw "topic-list-header-column" sortable=sortable number='true' order='likes' name='likes' ariaLabel=(i18n "sr_likes")}}
> {{/if}}
> {{#if showOpLikes}}
> {{raw "topic-list-header-column" sortable=sortable number='true' order='op_likes' name='likes' ariaLabel=(i18n "sr_op_likes")}}
> {{/if}}
> {{raw "topic-list-header-column" sortable=sortable number='true' order='created' name='created' ariaLabel=(i18n "sr_created")}}
> {{raw "topic-list-header-column" sortable=sortable number='true' order='activity' name='activity' ariaLabel=(i18n "sr_activity")}}
> {{raw-plugin-outlet name="topic-list-header-after"}}
> </script>
> 
> <script type='text/x-handlebars' data-template-name='list/topic-list-item.raw'>
> {{raw-plugin-outlet name="topic-list-before-columns"}}
>     
> {{#if bulkSelectEnabled}}
> <td class="bulk-select topic-list-data">
> <label for="bulk-select-{{topic.id}}">
> <input type="checkbox" class="bulk-select" id="bulk-select-{{topic.id}}">
> </label>
> </td>
> {{/if}}
>     
> {{!--
> The `~` syntax strip spaces between the elements, making it produce
> `<a>Some text</span>`
> with no space between them.
> This causes the topic-post-badge to be considered the same word as "text"
> at the end of the link, preventing it from line wrapping onto its own line.
> --}}
> <td class='main-link clearfix topic-list-data' colspan="1">
> {{raw-plugin-outlet name="topic-list-before-link"}}
> <span class='link-top-line'>
> {{raw-plugin-outlet name="topic-list-before-status"}}
> {{raw "topic-status" topic=topic}}
> {{topic-link topic class="raw-link raw-topic-link"}}
> {{#if topic.featured_link}}
> {{topic-featured-link topic}}
> {{/if}}
> {{raw-plugin-outlet name="topic-list-after-title"}}
> {{raw "list/unread-indicator" includeUnreadIndicator=includeUnreadIndicator
> topicId=topic.id
> unreadClass=unreadClass}}
> {{#if showTopicPostBadges}}
> {{raw "topic-post-badges" unreadPosts=topic.unread_posts unseen=topic.unseen url=topic.lastUnreadUrl newDotText=newDotText}}
> {{/if}}
> </span>
> <div class="link-bottom-line">
> {{#unless hideCategory}}
> {{#unless topic.isPinnedUncategorized}}
> {{raw-plugin-outlet name="topic-list-before-category"}}
> {{category-link topic.category}}
> {{/unless}}
> {{/unless}}
> {{discourse-tags topic mode="list" tagsForUser=tagsForUser}}
> {{raw "list/action-list" topic=topic postNumbers=topic.liked_post_numbers className="likes" icon="heart"}}
> </div>
> {{#if expandPinned}}
> {{raw "list/topic-excerpt" topic=topic}}
> {{/if}}
>     
> {{raw-plugin-outlet name="topic-list-main-link-bottom"}}
> </td>
>     
> {{raw-plugin-outlet name="topic-list-after-main-link"}}
>     
> {{#if showPosters}}
> {{raw "list/posters-column" posters=topic.featuredUsers}}
> {{/if}}
>     
> {{raw "list/posts-count-column" topic=topic}}
>     
> {{#if showLikes}}
> <td class="num likes topic-list-data">
> {{#if hasLikes}}
> <a href='{{topic.summaryUrl}}'>
> {{number topic.like_count}} {{d-icon "heart"}}
> </a>
> {{/if}}
> </td>
> {{/if}}
>     
> {{#if showOpLikes}}
> <td class="num likes">
> {{#if hasOpLikes}}
> <a href='{{topic.summaryUrl}}'>
> {{number topic.op_like_count}} {{d-icon "heart"}}
> </a>
> {{/if}}
> </td>
> {{/if}}
> 
> <td class="num topic-list-data {{cold-age-class topic.createdAt startDate=topic.bumpedAt class=""}} activity" title="{{html-safe topic.bumpedAtTitle}}">
> <a class="post-activity" href="{{topic.url}}">
> {{raw-plugin-outlet name="topic-list-before-relative-date"}}
> {{format-date topic.createdAt format="tiny" noTitle="true"}}
> </a>
> </td>
> 
> {{raw "list/activity-column" topic=topic class="num topic-list-data" tagName="td"}}
> </script>
> 
> ```

* * *

 ![image](https://global.discourse-cdn.com/meta/original/4X/0/b/2/0b28857776cc170b86223e19210e2974210ec934.png)

_注意：它在悬停时的标题与“Activity”相同，单击日期会重定向到帖子的开头。_

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [2023年三月25日 06:50 UTC](https://meta.discourse.org/t/changing-views-to-creating-date/253460/3 "2023-03-25T06:50:38Z")

</div>

谢谢！

运行正常。

> **不过，有个小小的注意事项**
>
> 它似乎会关闭“主题列表预览”插件。
> 
> - 首先——那段代码确实是个很好的姿态，而且如预期般工作。这真的超出了我的期望。
> - 其次——取决于论坛如何显示较长的日期（我使用的是 dd.mm.yy），如果同时启用此功能和 TLP，空间会很紧张。这是一种取舍，不能两者兼得。
> - 第三——我认为“主题列表预览”是一个非常复杂的插件。很容易与之产生冲突。再说一遍：这是个选择问题。

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [2023年三月25日 12:38 UTC](https://meta.discourse.org/t/changing-views-to-creating-date/253460/4 "2023-03-25T12:38:16Z")

</div>

感谢测试！

如果您使用 [https://meta.discourse.org/t/topic-list-previews-theme-component/209973（插件版本已弃用），您可以从仓库中复制粘贴以下内容，使用](https://meta.discourse.org/t/topic-list-previews-theme-component/209973%EF%BC%88%E6%8F%92%E4%BB%B6%E7%89%88%E6%9C%AC%E5%B7%B2%E5%BC%83%E7%94%A8%EF%BC%89%EF%BC%8C%E6%82%A8%E5%8F%AF%E4%BB%A5%E4%BB%8E%E4%BB%93%E5%BA%93%E4%B8%AD%E5%A4%8D%E5%88%B6%E7%B2%98%E8%B4%B4%E4%BB%A5%E4%B8%8B%E5%86%85%E5%AE%B9%EF%BC%8C%E4%BD%BF%E7%94%A8) [topic-list-item code](https://github.com/paviliondev/discourse-tc-topic-list-previews/blob/master/javascripts/discourse/templates/list/topic-list-item.hbr)。

> **头部**
>
> ```js
> <script type='text/x-handlebars' data-template-name='topic-list-header.raw'>
> {{raw-plugin-outlet name="topic-list-header-before"}}
> {{#if bulkSelectEnabled}}
> <th class="bulk-select topic-list-data">
> {{#if canBulkSelect}}
> {{raw "flat-button" class="bulk-select" icon="list" title="topics.bulk.toggle"}}
> {{/if}}
> </th>
> {{/if}}
> {{raw "topic-list-header-column" order='default' name=listTitle bulkSelectEnabled=bulkSelectEnabled showBulkToggle=toggleInTitle canBulkSelect=canBulkSelect canDoBulkActions=canDoBulkActions}}
> {{raw-plugin-outlet name="topic-list-header-after-main-link"}}
> {{#if showPosters}}
> {{raw "topic-list-header-column" order='posters' ariaLabel=(i18n "category.sort_options.posters")}}
> {{/if}}
> {{raw "topic-list-header-column" sortable=sortable number='true' order='posts' name='replies' ariaLabel=(i18n "sr_replies")}}
> {{#if showLikes}}
> {{raw "topic-list-header-column" sortable=sortable number='true' order='likes' name='likes' ariaLabel=(i18n "sr_likes")}}
> {{/if}}
> {{#if showOpLikes}}
> {{raw "topic-list-header-column" sortable=sortable number='true' order='op_likes' name='likes' ariaLabel=(i18n "sr_op_likes")}}
> {{/if}}
> {{raw "topic-list-header-column" sortable=sortable number='true' order='created' name='created' ariaLabel=(i18n "sr_created")}}
> {{raw "topic-list-header-column" sortable=sortable number='true' order='activity' name='activity' ariaLabel=(i18n "sr_activity")}}
> {{raw-plugin-outlet name="topic-list-header-after"}}
> </script>
> 
> <script type='text/x-handlebars' data-template-name='list/topic-list-item.raw'>
> {{#if bulkSelectEnabled}}
> <td class='star'>
> <input type="checkbox" class="bulk-select">
> </td>
> {{/if}}
>     
> {{#if tilesStyle}}
> <div class="tiles-grid-item-content main-link">
> <div class="image">
> {{#if hasThumbnail}}
> {{raw "list/topic-thumbnail" topic=topic thumbnails=thumbnails currentUser=currentUser site=site category=category opts=thumbnailOpts}}
> {{/if}}
> <a href='{{topic.url}}'>
> <div class="image-mask" style="{{backgroundGradient}}"></div>
> </a>
> </div>
> <div class="topic-details">
> <div class="topic-header-grid">
> {{raw "list/topic-list-title" topic=topic tilesStyle=tilesStyle showTopicPostBadges=showTopicPostBadges}}
> <div class="topic-category">
> {{#if showCategoryBadge}}
> {{category-link topic.category}}
> {{/if}}
> {{#if topic.tags}}
> {{discourse-tags topic mode="list"}}
> {{/if}}
> </div>
> </div>
> {{#if showExcerpt}}
> <a href='{{topic.url}}'>
> {{raw "list/topic-excerpt" topic=topic}}
> </a>
> {{/if}}
> <div class="topic-footer">
> {{raw 'list/topic-meta' likesHeat=likesHeat title=view.title topic=topic}}
> {{raw "list/topic-users" tilesStyle=tilesStyle abbreviatePosters=abbreviatePosters posters=abbreviatedPosters posterNames=posterNames}}
> {{#if showActions}}
> {{raw "list/topic-actions" likeCount=likeCount topicActions=topicActions topic=topic}}
> {{/if}}
> </div>
> </div>
> </div>
> {{else}}
> {{~raw-plugin-outlet name="topic-list-before-columns"}}
> {{!--
> The `~` syntax strip spaces between the elements, making it produce
> `<a>Some text</a><span>`，
> with no space between them.
> This causes the topic-post-badge to be considered the same word as "text"
> at the end of the link, preventing it from line wrapping onto its own line.
> --}}
> <td class='main-link clearfix topic-list-data' colspan="1">
> {{#if hasThumbnail}}
> {{raw "list/topic-thumbnail" topic=topic thumbnails=thumbnails category=category opts=thumbnailOpts}}
> {{/if}}
> {{~raw-plugin-outlet name="topic-list-before-link"}}
> <span class='link-top-line'>
> {{~raw-plugin-outlet name="topic-list-before-status"}}
> {{~raw "topic-status" topic=topic}}
> {{~topic-link topic class="raw-link raw-topic-link"}}
> {{~#if topic.featured_link}}
> {{~topic-featured-link topic}}
> {{~/if}}
> {{~raw-plugin-outlet name="topic-list-after-title"}}
> {{~raw "list/unread-indicator" includeUnreadIndicator=includeUnreadIndicator
> topicId=topic.id
> unreadClass=unreadClass~}}
> {{~#if showTopicPostBadges}}
> {{~raw "topic-post-badges" unreadPosts=topic.unread_posts unseen=topic.unseen url=topic.lastUnreadUrl newDotText=newDotText}}
> {{~/if}}
> </span>
> <div class="link-bottom-line">
> {{#unless hideCategory}}
> {{#unless topic.isPinnedUncategorized}}
> {{~raw-plugin-outlet name="topic-list-before-category"}}
> {{category-link topic.category}}
> {{/unless}}
> {{/unless}}
> {{discourse-tags topic mode="list" tagsForUser=tagsForUser}}
> {{#if expandPinned}}
> {{raw "list/topic-excerpt" topic=topic}}
> {{/if}}
> {{#if showActions}}
> {{raw "list/topic-actions" likeCount=likeCount topicActions=topicActions}}
> {{/if}}
> {{raw "list/action-list" topic=topic postNumbers=topic.liked_post_numbers className="likes" icon="heart"}}
> </div>
> </td>
>     
> {{#if showPosters}}
> {{raw "list/posters-column" posters=topic.featuredUsers}}
> {{/if}}
>     
> {{raw "list/posts-count-column" topic=topic}}
>     
> {{#if showLikes}}
> <td class="num likes topic-list-data">
> {{#if hasLikes}}
> <a href='{{topic.summaryUrl}}'>
> {{number topic.like_count}} {{d-icon "heart"}}
> </a>
> {{/if}}
> </td>
> {{/if}}
>     
> {{#if showOpLikes}}
> <td class="num likes">
> {{#if hasOpLikes}}
> <a href='{{topic.summaryUrl}}'>
> {{number topic.op_like_count}} {{d-icon "heart"}}
> </a>
> {{/if}}
> </td>
> {{/if}}
>     
> <td class="num topic-list-data {{cold-age-class topic.createdAt startDate=topic.bumpedAt class=""}} activity" title="{{html-safe topic.bumpedAtTitle}}">
> <a class="post-activity" href="{{topic.url}}">
> {{~raw-plugin-outlet name="topic-list-before-relative-date"~}}
> {{~format-date topic.createdAt format="tiny" noTitle="true"~}}
> </a>
> </td>
>     
> {{raw "list/activity-column" topic=topic class="num topic-list-data" tagName="td"}}
> {{/if}}
> </script>
> 
> ```

 ![image](https://global.discourse-cdn.com/meta/original/4X/5/b/6/5b650c39149517f4b8f12306b18b1e4c45b5394f.png)

请告诉我这是否对您有帮助。 🙂

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [2023年三月25日 14:46 UTC](https://meta.discourse.org/t/changing-views-to-creating-date/253460/5 "2023-03-25T14:46:25Z")

</div>

> [@Arkshine](#):
>
> 如果你使用

两者都用。边车插件没有被弃用，对吧？

不过我今天晚些时候会试试。我这里快下午五点了，这意味着我得开始热桑拿了 😉 所以，最重要的事情先来 🤣

（给版主和管理员：这不是离题，而是现实世界的用户体验……）

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [2023年三月25日 15:24 UTC](https://meta.discourse.org/t/changing-views-to-creating-date/253460/6 "2023-03-25T15:24:48Z")

</div>

> [@Jagster](#):
>
> 侧边栏插件没有被弃用，对吗？

是的，侧边栏插件是对主题组件的补充，这里没问题。
