summaryrefslogtreecommitdiff
path: root/app/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/content_helper.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/app/helpers/content_helper.rb b/app/helpers/content_helper.rb
index 385bca0..9800471 100644
--- a/app/helpers/content_helper.rb
+++ b/app/helpers/content_helper.rb
@@ -1,9 +1,25 @@
1module ContentHelper 1module ContentHelper
2 2
3 # Returns the published_at attribute of a page if it is not nil, otherwise
4 # it returns the auto-filled value of the created_at attribute
3 def date_for_page page 5 def date_for_page page
4 page.published_at.to_s(:db) rescue page.created_at.to_s(:db) 6 page.published_at.to_s(:db) rescue page.created_at.to_s(:db)
5 end 7 end
6 8
9 # This method is an output filter for templates. It accepts any kind of text
10 # and checks for an <aggregate /> tag within it. If such a tag is found, its
11 # attributes are parsed and converted into parameters for the
12 # render_collection method. The <aggregate /> tag will then be replaced
13 # entirely with the output of the render_collection method.
14 #
15 # Syntax of the <aggregate /> tag:
16 #
17 # <aggregate
18 # flags="update, pressemitteilung"
19 # limit="20"
20 # order_by="published_at"
21 # order_direction="DESC"
22 # />
7 def aggregate? content 23 def aggregate? content
8 options = {} 24 options = {}
9 25
@@ -27,6 +43,8 @@ module ContentHelper
27 end 43 end
28 end 44 end
29 45
46 # Takes the parameters from the aggregate? method and renders the collection
47 # from Page.aggregate(options) with a given partial
30 def render_collection options 48 def render_collection options
31 render( 49 render(
32 :partial => 'content/article', 50 :partial => 'content/article',