def navigation_widget_breadcrumbs(self): """Views for the "breadcrumbs" display type, which is essentially the same as Kotti's default breadcrumbs display, except that here you have control of the associated label. - They each use the general navigation_widget_breadcrumbs() function. """ resource_group.need() root = get_root() options = get_setting(self.location + "_options", default=[]) include_root = "include_root" in options label = parse_label(self.context.title, get_setting(self.location + "_label")) # When the nav display is set to the beforebodyend slot, the class # for the containing div needs to be 'container' so it fits to the # middle span12 area for content. When nav is in any of the other # slots, no class is needed, because the inherited CSS works to fit # nav to the slot. use_container_class = self.location == "beforebodyend" lineage_items = get_lineage(self.context, self.request, self.location) if not include_root and root in lineage_items: lineage_items.remove(root) lineage_items.reverse() return { "location": self.location, "use_container_class": use_container_class, "label": label, "lineage_items": lineage_items, }
def navigation_widget_menu(context, request, name=''): """Views for the "menu" display type, which consists of a single button with a dropdown for presenting a full site context menu. - They each use the general navigation_widget_menu() view function. - The menu can be used standalone as the only nav display in a given location, or it can be combined with a label and/or another display type, e.g. a horizontal items nav display. """ # Assume top location, unless name or request.path are available. location = 'top' if name: location = name[name.rfind('-') + 1:] elif 'navigation-widget' in request.path: location = location_from_path(request.path) resource_group.need() root = get_root() settings = navigation_settings() include_root = asbool(settings['{0}_include_root'.format(location)]) # When the nav display is set to the beforebodyend slot, the class for the # containing div needs to be 'container' so it fits to the middle span12 # area for content. When nav is in any of the other slots, no class is # needed, because the inherited CSS works to fit nav to the slot. use_container_class = True if location == 'beforebodyend' else False items = get_children(context, request, location) top_level_items = get_children(root, request, location) # The lineage function of pyramid is used to make a breadcrumbs-style # display for the context menu. lineage_items = get_lineage(context, request, location) if not include_root and root in lineage_items: lineage_items.remove(root) # The lineage comes back in root-last order, so reverse. lineage_items.reverse() # The lineage (breadcrumbs style) display in navigation.pt shows # lineage_items in an indented dropdown list, and below that has a li # repeat on items, indented beneath context. return { 'root': root, 'location': location, 'items': items, 'use_container_class': use_container_class, 'include_root': include_root, 'top_level_items': top_level_items, 'lineage_items': lineage_items }
def navigation_widget_menu(context, request, name=''): """Views for the "menu" display type, which consists of a single button with a dropdown for presenting a full site context menu. - They each use the general navigation_widget_menu() view function. - The menu can be used standalone as the only nav display in a given location, or it can be combined with a label and/or another display type, e.g. a horizontal items nav display. """ # Assume top location, unless name or request.path are available. location = 'top' if name: location = name[name.rfind('-') + 1:] elif 'navigation-widget' in request.path: location = location_from_path(request.path) resource_group.need() root = get_root() settings = navigation_settings() include_root = asbool(settings['{0}_include_root'.format(location)]) # When the nav display is set to the beforebodyend slot, the class for the # containing div needs to be 'container' so it fits to the middle span12 # area for content. When nav is in any of the other slots, no class is # needed, because the inherited CSS works to fit nav to the slot. use_container_class = True if location == 'beforebodyend' else False items = get_children(context, request, location) top_level_items = get_children(root, request, location) # The lineage function of pyramid is used to make a breadcrumbs-style # display for the context menu. lineage_items = get_lineage(context, request, location) if not include_root and root in lineage_items: lineage_items.remove(root) # The lineage comes back in root-last order, so reverse. lineage_items.reverse() # The lineage (breadcrumbs style) display in navigation.pt shows # lineage_items in an indented dropdown list, and below that has a li # repeat on items, indented beneath context. return {'root': root, 'location': location, 'items': items, 'use_container_class': use_container_class, 'include_root': include_root, 'top_level_items': top_level_items, 'lineage_items': lineage_items}
def navigation_widget_menu(self): """Views for the "menu" display type, which consists of a single button with a dropdown for presenting a full site context menu. - They each use the general navigation_widget_menu() view function. - The menu can be used standalone as the only nav display in a given location, or it can be combined with a label and/or another display type, e.g. a horizontal items nav display. """ resource_group.need() root = get_root() options = get_setting(self.location + "_options", default=[]) include_root = "include_root" in options # When the nav display is set to the beforebodyend slot, the class # for the containing div needs to be 'container' so it fits to the # middle span12 area for content. When nav is in any of the other # slots, no class is needed, because the inherited CSS works to fit # nav to the slot. use_container_class = self.location == "beforebodyend" items = get_children(self.context, self.request, self.location) top_level_items = get_children(root, self.request, self.location) # The lineage function of pyramid is used to make a breadcrumbs-style # display for the context menu. lineage_items = get_lineage(self.context, self.request, self.location) if not include_root and root in lineage_items: lineage_items.remove(root) # The lineage comes back in root-last order, so reverse. lineage_items.reverse() # The lineage (breadcrumbs style) display in navigation.pt shows # lineage_items in an indented dropdown list, and below that has a li # repeat on items, indented beneath context. return { "root": root, "location": self.location, "items": items, "use_container_class": use_container_class, "include_root": include_root, "top_level_items": top_level_items, "lineage_items": lineage_items, }
def navigation_widget_breadcrumbs(context, request, name=''): """Views for the "breadcrumbs" display type, which is essentially the same as Kotti's default breadcrumbs display, except that here you have control of the associated label. - They each use the general navigation_widget_breadcrumbs() function. """ # Assume top location, unless name or request.path are available. location = 'top' if name: location = name[name.rfind('-') + 1:] elif 'navigation-widget' in request.path: location = location_from_path(request.path) resource_group.need() root = get_root() settings = navigation_settings() include_root = asbool(settings['{0}_include_root'.format(location)]) label = parse_label(context.title, settings['{0}_label'.format(location)]) # When the nav display is set to the beforebodyend slot, the class for the # containing div needs to be 'container' so it fits to the middle span12 # area for content. When nav is in any of the other slots, no class is # needed, because the inherited CSS works to fit nav to the slot. use_container_class = True if location == 'beforebodyend' else False lineage_items = get_lineage(context, request, location) if not include_root and root in lineage_items: lineage_items.remove(root) lineage_items.reverse() return { 'location': location, 'use_container_class': use_container_class, 'label': label, 'lineage_items': lineage_items }
def navigation_widget_breadcrumbs(context, request, name=''): """Views for the "breadcrumbs" display type, which is essentially the same as Kotti's default breadcrumbs display, except that here you have control of the associated label. - They each use the general navigation_widget_breadcrumbs() function. """ # Assume top location, unless name or request.path are available. location = 'top' if name: location = name[name.rfind('-') + 1:] elif 'navigation-widget' in request.path: location = location_from_path(request.path) resource_group.need() root = get_root() settings = navigation_settings() include_root = asbool(settings['{0}_include_root'.format(location)]) label = parse_label(context.title, settings['{0}_label'.format(location)]) # When the nav display is set to the beforebodyend slot, the class for the # containing div needs to be 'container' so it fits to the middle span12 # area for content. When nav is in any of the other slots, no class is # needed, because the inherited CSS works to fit nav to the slot. use_container_class = True if location == 'beforebodyend' else False lineage_items = get_lineage(context, request, location) if not include_root and root in lineage_items: lineage_items.remove(root) lineage_items.reverse() return {'location': location, 'use_container_class': use_container_class, 'label': label, 'lineage_items': lineage_items}