mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 11:48:08 +08:00
show parent and child category in oneboxes
This commit is contained in:
@ -58,9 +58,14 @@ module Onebox
|
|||||||
end
|
end
|
||||||
|
|
||||||
category_name = ''
|
category_name = ''
|
||||||
|
parent_category_name = ''
|
||||||
category = topic.category
|
category = topic.category
|
||||||
if category && !category.uncategorized?
|
if category && !category.uncategorized?
|
||||||
category_name = "<a href=\"#{category.url}\" class=\"badge badge-category\" style=\"background-color: ##{category.color}; color: ##{category.text_color}\">#{category.name}</a>"
|
category_name = "<a href=\"#{category.url}\" class=\"badge badge-category\" style=\"background-color: ##{category.color}; color: ##{category.text_color}\">#{category.name}</a>"
|
||||||
|
if !category.parent_category_id.nil?
|
||||||
|
parent_category = Category.find_by(id: category.parent_category_id)
|
||||||
|
parent_category_name = "<a href=\"#{parent_category.url}\" class=\"badge badge-category\" style=\"background-color: ##{parent_category.color}; color: ##{parent_category.text_color}\">#{parent_category.name}</a>"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
quote = post.excerpt(SiteSetting.post_onebox_maxlength)
|
quote = post.excerpt(SiteSetting.post_onebox_maxlength)
|
||||||
@ -73,6 +78,7 @@ module Onebox
|
|||||||
posters: posters,
|
posters: posters,
|
||||||
quote: quote,
|
quote: quote,
|
||||||
category_name: category_name,
|
category_name: category_name,
|
||||||
|
parent_category_name: parent_category_name,
|
||||||
topic: topic.id
|
topic: topic.id
|
||||||
|
|
||||||
@template = 'topic'
|
@template = 'topic'
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<div class='title'>
|
<div class='title'>
|
||||||
<div class='quote-controls'></div>
|
<div class='quote-controls'></div>
|
||||||
{{{avatar}}}
|
{{{avatar}}}
|
||||||
<a href="{{original_url}}">{{title}}</a> {{{category_name}}}
|
<a href="{{original_url}}">{{title}}</a> {{{parent_category_name}}} {{{category_name}}}
|
||||||
</div>
|
</div>
|
||||||
<blockquote>{{{quote}}}
|
<blockquote>{{{quote}}}
|
||||||
<div class='topic-info'>
|
<div class='topic-info'>
|
||||||
|
Reference in New Issue
Block a user