def is_subsection(self, context, view): # if isDefaultPage(context): # if ISectionIntro.providedBy(context) or ISectionIntro.providedBy(view): return False while not INavigationRoot.providedBy(context): context = aq_parent(context) if ISectionIntro.providedBy(context): return True default_page = getDefaultPage(context, self.request) if default_page and ISectionIntro.providedBy( getattr(context, default_page)): return True return False
def bodyClass(self, template, view): """Returns the CSS class to be used on the body tag.""" body_class = super(LayoutPolicy, self).bodyClass(template, view) # is_special is set to True if we do not want the default subsection # view. This is the case when a different layout has been explicitly # set, or we are viewing certain content types. specials = ["template-newsitem_view", "template-event_view"] is_special = False for special in specials: if special in body_class: is_special = True # is there a marker interface for 2 images on the context or view? if ITwoImages.providedBy(self.context) or ITwoImages.providedBy(view): body_class += " two-images" is_special = True # is there a marker interface for section intro? if ISectionIntro.providedBy(self.context) or \ ISectionIntro.providedBy(view): body_class += " section-intro" is_special = True # is there a marker interface for 2 full width? if IFullWidth.providedBy(self.context) or IFullWidth.providedBy(view): body_class += " full-width" is_special = True # is there a marker interface for materials view? if IMaterialsView.providedBy(self.context) or \ IMaterialsView.providedBy(view): body_class += " materials-view" is_special = True if not is_special and self.is_subsection(self.context, view): body_class += " subsection" return body_class