Change for page: take category and tag at the same time

This commit is contained in:
Christophe Vilayphiou committed 2012-08-01 16:33:46 +08:00
1 parent 625801c0e9
commit 25a911b4f8
3 files changed
+10 -3

No files matched your search

+8 -1
View File
@@ -62,7 +62,14 @@ class PagesController < ApplicationController
def get_item
module_app = ModuleApp.first(:conditions => {:key => params[:app_name]})
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action]})
if !params[:category_id].blank? && !params[:tag_id].blank?
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => params[:tag_id]})
elsif !params[:category_id].blank?
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id]})
elsif !params[:tag_id].blank?
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :tag => params[:tag_id]})
end
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action]}) unless @item
#TODO 需要做 error handler 處理沒有新增該模組頁面導致錯誤的可能性
end