Skip to content

Instantly share code, notes, and snippets.

@facuescobar
Created October 6, 2016 15:37
Show Gist options
  • Save facuescobar/9c9897a0e9f22b6027a8ed5dbc75b173 to your computer and use it in GitHub Desktop.
Save facuescobar/9c9897a0e9f22b6027a8ed5dbc75b173 to your computer and use it in GitHub Desktop.
load_skeleton_for_section_as_frontpage module
@handlers.register(condition=lambda obj: obj.env.site.extra.get('use_section_as_homepage') and obj.env.page_type == page_types.FRONTPAGE)
def load_skeleton_for_section_as_frontpage(self):
subpage_template_name = None
for subpage in Subpages.get_subpages(self.env.site.id):
if subpage.get('is_homepage', False):
subpage_template_name = u'section_{}.xml'.format(subpage['url'].lower())
break
if subpage_template_name:
try:
return load_skeleton_from(self.env, subpage_template_name)
except SkeletonNotFound:
pass
return load_skeleton_from(self.env, 'subpage.xml')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment