add widget count

This commit is contained in:
JiangRu 2015-02-06 17:04:39 +08:00
parent 09ae60a172
commit 481f345382
2 changed files with 5 additions and 3 deletions

View File

@ -36,6 +36,7 @@ class GalleriesController < ApplicationController
def widget
albums = Album.filter_by_widget_categories
params = OrbitHelper.params
counts = OrbitHelper.widget_data_count
images = []
total_images = 0
@ -43,8 +44,8 @@ class GalleriesController < ApplicationController
albums.each do |album|
total_images = total_images + album.album_images.count
end
total_images = total_images > 9 ? 9 : total_images
while images.count < total_images and images.count < AlbumImage.count
total_images = counts > 9 ? 9 : counts
while images.count < counts and images.count < AlbumImage.count
albums.each do |album|
img = album.album_images.sample
if !images.include?(img) && img != nil

View File

@ -5,7 +5,8 @@ module Gallery
module_label "gallery.gallery"
base_url File.expand_path File.dirname(__FILE__)
widget_methods ["widget"]
widget_settings []
# widget_settings []
widget_settings [{"data_count"=>10}]
categorizable
authorizable
frontend_enabled