forked from saurabh/orbit4-5
update tag
This commit is contained in:
parent
527648da0a
commit
925001ca3f
|
@ -0,0 +1,22 @@
|
|||
<!--
|
||||
Announcement index-2
|
||||
Fields: widget-title, date-head, title-head, postdate, title, pagination
|
||||
-->
|
||||
<div class="i-announcement annc-index-3 i-announcement--table">
|
||||
<h3 class="i-announcement__widget-title">{{widget-title}}</h3>
|
||||
<table class="i-announcement__table">
|
||||
<tbody class="i-announcement__tbody" data-level="0" data-list="announcements">
|
||||
<tr>
|
||||
<td>
|
||||
<a class="i-announcement__link i-announcement__td--link" href="{{link_to_show}}">{{title}}</a>
|
||||
</td>
|
||||
<td>
|
||||
<span class="i-announcement__date i-announcement__td--postdate" date-format="%Y-%m-%d">{{postdate}}</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{pagination_goes_here}}
|
||||
<div class="i-sidebar">
|
||||
</div>
|
|
@ -15,6 +15,14 @@
|
|||
"en" : "2. Text without image (widget-title, postdate, title)"
|
||||
},
|
||||
"thumbnail" : "thumbnail-block-list.png"
|
||||
},
|
||||
{
|
||||
"filename" : "annc_index3",
|
||||
"name" : {
|
||||
"zh_tw" : "3. 純文字無圖片(沒有sidebar) ( 模組標題, 日期, 標題 )",
|
||||
"en" : "3. Text without image and no sidebar (widget-title, postdate, title)"
|
||||
},
|
||||
"thumbnail" : "thumbnail-block-list.png"
|
||||
}
|
||||
],
|
||||
"widgets" : [
|
||||
|
|
|
@ -60,7 +60,7 @@ en:
|
|||
transition_sec: Transition time
|
||||
update_banner: Update Banner
|
||||
upload_pictures: Upload pictures
|
||||
widget_info_for_ad_image_size: "Best size with: %{best_size}"
|
||||
widget_info_for_ad_image_size: "Uploading image ratio is 2:1 (image width:height), ex %{best_size}"
|
||||
event_calendar: Event Calendar
|
||||
add_attribute_field: Add attribute field
|
||||
add_image: Add image
|
||||
|
|
|
@ -39,7 +39,7 @@ zh_tw:
|
|||
transition_sec: 轉場單位時間
|
||||
update_banner: 更新輪播
|
||||
upload_pictures: 上傳圖片
|
||||
widget_info_for_ad_image_size: "此區塊圖片尺寸使用: %{best_size}"
|
||||
widget_info_for_ad_image_size: "此區塊圖片尺寸使用比例為 2:1( 圖片寬:高 ),例如 %{best_size}"
|
||||
ad_banner: 廣告輪播
|
||||
ad_banner:
|
||||
add: 新增
|
||||
|
|
|
@ -10,29 +10,33 @@ module OrbitTag
|
|||
module ClassMethods
|
||||
def with_tags(tags=[])
|
||||
tags = [tags].flatten.uniq
|
||||
result = []
|
||||
# result = []
|
||||
if tags.blank?
|
||||
self.all
|
||||
else
|
||||
self.all.each do |taggable|
|
||||
result << taggable if (taggable.taggings.map{|t| t.tag.id.to_s } & tags).size > 0
|
||||
end
|
||||
self.where(:id.in=>result.map{|taggable| taggable.id})
|
||||
# self.all.each do |taggable|
|
||||
# result << taggable if (taggable.taggings.map{|t| t.tag.id.to_s } & tags).size > 0
|
||||
# end
|
||||
# self.where(:id.in=>result.map{|taggable| taggable.id})
|
||||
taggings = Tagging.where(:tag_id.in=>tags).map{|item| item.taggable_id}
|
||||
self.where(:id.in=>taggings)
|
||||
end
|
||||
end
|
||||
|
||||
def filter_by_tags(tags=[])
|
||||
tags = OrbitHelper.page_tags if tags.blank?
|
||||
tags = [tags].flatten.uniq
|
||||
result = []
|
||||
# result = []
|
||||
|
||||
if tags.blank? or (tags.include?("all") rescue false)
|
||||
self.all
|
||||
else
|
||||
self.all.each do |taggable|
|
||||
result << taggable if (taggable.taggings.map{|t| t.tag.id.to_s } & tags).size > 0
|
||||
end
|
||||
self.where(:id.in=>result.map{|taggable| taggable.id})
|
||||
# self.all.each do |taggable|
|
||||
# result << taggable if (taggable.taggings.map{|t| t.tag.id.to_s } & tags).size > 0
|
||||
# end
|
||||
# self.where(:id.in=>result.map{|taggable| taggable.id})
|
||||
taggings = Tagging.where(:tag_id.in=>tags).map{|item| item.taggable_id}
|
||||
self.where(:id.in=>taggings)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue