Created
February 19, 2010 05:32
-
-
Save nicholasf/308464 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # the sitemap portlet | |
| # takes two inputs via the form - a top level section to map beneath (defaults to root section) and a list of sections to exclude from map | |
| class SitemapPortlet < Portlet | |
| # render_inline false | |
| def render | |
| top_level = self.section | |
| if top_level.empty? or top_level.nil? | |
| @section = Section.find_by_root(true) | |
| else | |
| @section = Section.find_by_name(top_level) | |
| end | |
| @excluded_sections = [] | |
| if self.exclude | |
| exclusion_list = self.exclude.split(",") | |
| exclusion_list.each do |section_name| | |
| section = Section.find_by_name(section_name.strip) | |
| @excluded_sections << section if section | |
| end | |
| end | |
| end | |
| end | |
| #render.html.ren | |
| # Patrick - please note that this template is in Renshi (a templating language I wrote, you can find it on my github profile or install the gem). | |
| # It should be very easy to map into ERB. Sorry, didn't have time to do so. | |
| $[i = 0] | |
| <table width="100%"> | |
| $[for section in @section.sections | |
| next unless (section.groups & current_user.groups).any? | |
| next if @excluded_sections.include?(section) | |
| i += 1 | |
| if i == 1] | |
| <tr> | |
| $[end] | |
| <td valign=top> | |
| $section.name | |
| <ul> | |
| <li r:for="page in section.pages">${link_to page.name, "#{page.path}"}</li> | |
| </ul> | |
| </td> | |
| $[i = 0 if i == 2] | |
| $[end] | |
| </table> | |
| #_form.html.ren | |
| ${ f.cms_text_field :name } | |
| ${ f.cms_text_field :section, :instructions => "Show sections including and beneath. Leave blank for / section." } | |
| ${ f.cms_text_field :exclude, :instructions => "Comma separated list of sections to exclude" } | |
| ${ f.cms_drop_down :handler, ActionView::Template.template_handler_extensions, :default => "erb" } | |
| ${ f.cms_text_area :template, :default_value => @block.class.default_template } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment