有没有一种方法可以获取我从 category.subcategories 中接收到的子类别的最新主题?我可以使用 category.latestTopic 来获取主类别的最新主题,但无法将其用于子类别。有什么巧妙的解决方法吗?我希望在列出子类别时显示子类别的最新主题。
I’m not 100% sure of the context (can you post your code?) but I think you should be able to treat subcategories the same as parent categories.
So category.latestTopic would work the same for any category/subcategory. If you loop through each of the subcategories using category.subcategories you should be able to use category.latestTopic within that loop.
Hello, sadly it does not. behave the same way.
Inside:
<script type="text/x-handlebars" data-template-name="components/categories-only">
....
{{#each categories as |c|}}
...
I can use c.latestTopic
But inside after the above:
...
{{#each c.subcategories as |s|}}
...
I can’t use s.latestTopic It doesn’t return anything
Ohh I see now, thanks for the additional detail. It looks like we don’t include topics for subcategories on the category page at all, so using latestTopic definitely isn’t possible… I think the serializer would need to be modified in a plugin to accomplish this? (sorry, I’m not sure of the specifics for accomplishing that).
I don’t know, sadly I’m not that experienced with Discourse or Ruby or whatever part has to be modified.
I hope someone can come up with a solution, I’ve been trying this for days and weeks by now.