Skip to content

Commit 17766ab

Browse files
committed
Added support for using page templates in controllers
1 parent d313eb2 commit 17766ab

File tree

5 files changed

+27
-20
lines changed

5 files changed

+27
-20
lines changed

app/helpers/cms/application_helper.rb

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
# Methods added to this helper will be available to all templates in the cms.
22
module Cms
33
module ApplicationHelper
4-
5-
def page_title(*args)
6-
if args.first
7-
@controller.instance_variable_get("@template").instance_variable_set("@page_title", args.first)
8-
else
9-
@controller.instance_variable_get("@template").instance_variable_get("@page_title")
10-
end
11-
end
124

135
def searchable_sections(selected = nil)
146
root = Section.root.first
@@ -165,15 +157,6 @@ def url_with_mode(url, mode)
165157
end
166158
end
167159

168-
def tb_iframe(path, options={})
169-
# The order of the parameters matters. All parameters that should be sent to the server,
170-
# have to appear before TB_iframe. All parameters that shouldn't be sent to the server and
171-
# that are just there for Thickbox should be after TB_iframe
172-
{:height => 600, :width => 600, :modal => true}.merge(options).inject("#{path}&TB_iframe=true") do |s, (k,v)|
173-
s << "&#{k}=#{CGI::escape(v.to_s)}"
174-
end
175-
end
176-
177160
def determine_order(current_order, order)
178161
if current_order == order
179162
if order =~ / desc$/i

app/helpers/cms/page_helper.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
module Cms
22
module PageHelper
3+
def page_title(*args)
4+
if args.first
5+
@controller.instance_variable_get("@template").instance_variable_set("@page_title", args.first)
6+
else
7+
@controller.instance_variable_get("@template").instance_variable_get("@page_title")
8+
end
9+
end
10+
311
def current_page
412
@page
513
end
614

715
def container(name)
816
content = instance_variable_get("@content_for_#{name}")
9-
if logged_in? && @mode == "edit"
17+
if logged_in? && @page && @mode == "edit"
1018
render :partial => 'cms/pages/edit_container', :locals => {:name => name, :content => content}
1119
else
1220
content
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This is a module, not a helper, that is meant to be included
2+
# into controllers that want to use page templates for their layout
3+
module Cms
4+
module TemplateSupport
5+
def self.included(controller)
6+
controller.class_eval do
7+
include Cms::Authentication::Controller
8+
include Cms::ErrorHandling
9+
10+
helper Cms::PageHelper
11+
helper Cms::MenuHelper
12+
end
13+
end
14+
end
15+
end

browsercms.gemspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
66

77
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
88
s.authors = ["BrowserMedia"]
9-
s.date = %q{2009-06-30}
9+
s.date = %q{2009-07-03}
1010
s.email = %q{github@browsermedia.com}
1111
s.extra_rdoc_files = [
1212
"LICENSE.txt",
@@ -59,6 +59,7 @@ Gem::Specification.new do |s|
5959
"app/helpers/cms/page_helper.rb",
6060
"app/helpers/cms/path_helper.rb",
6161
"app/helpers/cms/section_nodes_helper.rb",
62+
"app/helpers/cms/template_support.rb",
6263
"app/models/abstract_file_block.rb",
6364
"app/models/attachment.rb",
6465
"app/models/category.rb",

lib/cms/init.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def version
1212
@version = SPEC.version.version
1313
end
1414

15-
def build_number; 250 end
15+
def build_number; 251 end
1616

1717
def load_rake_tasks
1818
load "#{Cms.root}/lib/tasks/cms.rake"

0 commit comments

Comments
 (0)