Sha256: 85cfdee10180bca51097451a1a651ee6db6ad57fafc7e6c78e9f8dbb530058dc

Contents?: true

Size: 920 Bytes

Versions: 1

Compression:

Stored size: 920 Bytes

Contents

class Plugins::CamaleonPostOrder::AdminController < CamaleonCms::Apps::PluginsAdminController
  include Plugins::CamaleonPostOrder::MainHelper
  # This updates the position of the elements in the database.
  def reorder_posts
    if params[:values].present?
      params[:values].each_with_index do |value,index |
        post = current_site.posts.find(value).update_column("post_order", index)
        # taxonomy_id = post.post_type.id
        # post.term_relationships.where("term_taxonomy_id = ?", taxonomy_id).first.update_column("term_order", index)
      end
    end

    render inline: "correct"
  end

  # show plugin settings.
  def settings

  end

  # This saves the settings plugin.
  def save_settings
    @plugin = current_plugin
    @plugin.set_meta("_reorder_objects", params[:object] || {})
    flash[:notice] = "#{t('plugin.post_reorder.updated_changes')}"

    redirect_to action: :settings
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
camaleon_post_order-0.0.2 app/controllers/plugins/camaleon_post_order/admin_controller.rb