Skip to content

Instantly share code, notes, and snippets.

@almonk
Last active August 29, 2015 14:27
Show Gist options
  • Save almonk/d8122196eec4cd736c73 to your computer and use it in GitHub Desktop.
Save almonk/d8122196eec4cd736c73 to your computer and use it in GitHub Desktop.
class Menu < Page
def entry?
true
end
def template
"menu_set/views/show"
end
# Uncomment the as_json method if the page defines fields that are
# shown in the admin UI. Pass a hash to merge() that contains each
# field.
#
# def as_json(options = {})
# super.merge(published: published.to_s)
# end
end
class MenuPresenter < PagePresenter
include EntryPresenter
# We need to tell the admin UI which fields to show when presenting a
# table of entries in the admin UI. Each key in the column hash should
# be a symbol matching the name of one of the fields defined on the
# page.
#
# The hash's values (e.g. 'Date Published') will be used for the
# column headings in the admin UI.
@columns = {
name: 'Name',
# published_at: 'Date Published'
}
class << self
attr_reader :columns
end
# If you want to display extra information while editing or creating a
# page (i.e. in the admin UI's side bar) you'll need to define some
# .hbs files, and then tell the CMS to use them by uncommenting these
# methods.
# def main_extra_template
# 'menu_set/menu_main'
# end
# def meta_extra_template
# 'menu_set/menu_meta'
# end
# The CMS needs to know how to present the data stored on a page;
# it's not always good enough just to convert it to a string and
# render it into the page. You can access the page through the @source
# variable.
def name
@source.name.blank? ? "(name isn't set)" : @source.name
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment