mirror of
https://github.com/discourse/discourse.git
synced 2025-02-21 19:55:43 +00:00
show parent and child category in oneboxes
This commit is contained in:
parent
943ad8d1d5
commit
e6c853e642
@ -58,9 +58,14 @@ module Onebox
|
||||
end
|
||||
|
||||
category_name = ''
|
||||
parent_category_name = ''
|
||||
category = topic.category
|
||||
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>"
|
||||
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
|
||||
|
||||
quote = post.excerpt(SiteSetting.post_onebox_maxlength)
|
||||
@ -73,6 +78,7 @@ module Onebox
|
||||
posters: posters,
|
||||
quote: quote,
|
||||
category_name: category_name,
|
||||
parent_category_name: parent_category_name,
|
||||
topic: topic.id
|
||||
|
||||
@template = 'topic'
|
||||
|
@ -2,7 +2,7 @@
|
||||
<div class='title'>
|
||||
<div class='quote-controls'></div>
|
||||
{{{avatar}}}
|
||||
<a href="{{original_url}}">{{title}}</a> {{{category_name}}}
|
||||
<a href="{{original_url}}">{{title}}</a> {{{parent_category_name}}} {{{category_name}}}
|
||||
</div>
|
||||
<blockquote>{{{quote}}}
|
||||
<div class='topic-info'>
|
||||
|
Loading…
x
Reference in New Issue
Block a user