Module: Nesta::Plugin::Subpages::Helpers

Defined in:
lib/nesta-plugin-subpages/init.rb

Instance Method Summary collapse

Instance Method Details

#subpages_for(page_or_path) ⇒ Object

Helper that takes a page or a string path to a page and returns any subpages if they exist, or an empty array otherwise.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/nesta-plugin-subpages/init.rb', line 9

def subpages_for(page_or_path)
  case page_or_path
  when Nesta::Page
    return page_or_path.subpages()
  when String
    page = Nesta::Page.find_by_path(page_or_path)
    return page.subpages if page
  end

  return []
end