foto gallery fix

This commit is contained in:
Andreas Stephanides
2014-02-07 22:15:51 +01:00
parent 1e36d810dc
commit 05dbffd4f6
2 changed files with 8 additions and 5 deletions

View File

@@ -27,8 +27,11 @@ class GalleriesController < ApplicationController
end end
@page = params[:page].nil? ? 1 : params[:page].to_i @page = params[:page].nil? ? 1 : params[:page].to_i
@fotos = Foto.where(:gallery_id => params[:id]).limit(@pppage_array[@pppage]).offset(@pppage_array[@pppage]*(@page-1)) # @fotos = Foto.where(:gallery_id => params[:id]).limit(@pppage_array[@pppage]).offset(@pppage_array[@pppage]*(@page-1))
@fotos = Foto.where(:gallery_id => params[:id])
@pages = (Foto.where(:gallery_id => params[:id]).count/(@pppage_array[@pppage])+1) @pages = (Foto.where(:gallery_id => params[:id]).count/(@pppage_array[@pppage])+1)
@showind=[]
@showind.fill(0,@pppage_array[@pppage]){ |i| i+ @pppage_array[@pppage]*(@page-1)} # Hier ausrechnen welche angezeigt werden sollen
@toolbar_elements << {:hicon=>'icon-plus', :text=> I18n.t('fotos.new-fotos'), :path=>new_gallery_foto_path(@gallery)} @toolbar_elements << {:hicon=>'icon-plus', :text=> I18n.t('fotos.new-fotos'), :path=>new_gallery_foto_path(@gallery)}
@toolbar_elements << {:hicon=>'icon-pencil', :text => I18n.t('common.edit'), :path=>edit_gallery_path(@gallery)} @toolbar_elements << {:hicon=>'icon-pencil', :text => I18n.t('common.edit'), :path=>edit_gallery_path(@gallery)}
@toolbar_elements << {:hicon=>'icon-arrow-left', :text=>I18n.t('common.back'), :path=>galleries_path()} @toolbar_elements << {:hicon=>'icon-arrow-left', :text=>I18n.t('common.back'), :path=>galleries_path()}

View File

@@ -56,10 +56,10 @@
</div> </div>
<div id="gallery" data-toggle="modal-gallery" data-target="#modal-gallery"> <div id="gallery" data-toggle="modal-gallery" data-target="#modal-gallery">
<% @fotos.each do |f| %> <% @fotos.each_index do |i| %>
<% f= @fotos[i] %>
<a href="<%= f.datei.resized.url%>" title="<%=f.title%>" data-gallery="gallery"> <a href="<%= f.datei.resized.url%>" title="<%=f.title%>" data-gallery="gallery">
<%=image_tag(f.datei.thumb.url,{:class=>"img-polaroid img-rounded"}) %></a> <%=image_tag(f.datei.thumb.url,{:class=>"img-polaroid img-rounded"}) if @showind.include? i %></a>
<% end %> <% end %>