diff --git a/db/migrate/20090822092032_add_skip_to_first_child_to_pages.rb b/db/migrate/20090822092032_add_skip_to_first_child_to_pages.rb new file mode 100644 index 0000000000..84d3bac0b7 --- /dev/null +++ b/db/migrate/20090822092032_add_skip_to_first_child_to_pages.rb @@ -0,0 +1,9 @@ +class AddSkipToFirstChildToPages < ActiveRecord::Migration + def self.up + add_column :pages, :skip_to_first_child, :boolean, :default => false + end + + def self.down + remove_column :pages, :skip_to_first_child + end +end diff --git a/db/schema.rb b/db/schema.rb index e7dae31c00..faec1d8934 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,7 +9,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20090618044141) do +ActiveRecord::Schema.define(:version => 20090822092032) do create_table "images", :force => true do |t| t.integer "parent_id" @@ -87,6 +87,7 @@ t.integer "custom_title_image_id" t.boolean "draft", :default => false t.string "browser_title" + t.boolean "skip_to_first_child", :default => false end create_table "portfolio_entries", :force => true do |t| diff --git a/vendor/plugins/pages/app/controllers/pages_controller.rb b/vendor/plugins/pages/app/controllers/pages_controller.rb index 005af38855..d41d07492e 100644 --- a/vendor/plugins/pages/app/controllers/pages_controller.rb +++ b/vendor/plugins/pages/app/controllers/pages_controller.rb @@ -7,6 +7,12 @@ def home def show @page = Page.find(params[:id], :include => [:parts, :slugs]) + + # if the admin wants this to be a "placeholder" page which goes to its first child, go to that instead. + if @page.skip_to_first_child + first_live_child = @page.children.find_by_draft(false, :order => "position ASC") + redirect_to page_url(first_live_child) unless first_live_child.nil? + end end end \ No newline at end of file diff --git a/vendor/plugins/pages/app/views/admin/pages/_form.html.erb b/vendor/plugins/pages/app/views/admin/pages/_form.html.erb index e2ef7556b5..4bee07a8c0 100644 --- a/vendor/plugins/pages/app/views/admin/pages/_form.html.erb +++ b/vendor/plugins/pages/app/views/admin/pages/_form.html.erb @@ -68,6 +68,11 @@ +
+ <%= label_tag :skip_to_first_child? %> + <%= f.check_box :skip_to_first_child %> + <%= f.label :skip_to_first_child, "Check this box if you want the visitor to be redirected to this page's first child page if this page is selected.", :class => "stripped" %> +
<%= f.label :link_url, "Custom URL" %> <%= f.text_field :link_url, {:size => 103} %>