- Timestamp:
- 11/13/08 11:53:39 (16 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/pylucid_project/PyLucid/plugins_internal/main_menu/main_menu.py
r1634 r1792 18 18 Last commit info: 19 19 ~~~~~~~~~~~~~~~~~ 20 $LastChangedDate :$20 $LastChangedDate$ 21 21 $Rev$ 22 $Author :$22 $Author$ 23 23 24 24 :copyleft: 2007 by the PyLucid team, see AUTHORS for more details. … … 37 37 class main_menu(PyLucidBasePlugin): 38 38 39 def lucidTag(self ):39 def lucidTag(self, min=1, max=0): 40 40 """ 41 41 write the current opened tree menu … … 43 43 current_page = self.context["PAGE"] 44 44 self.current_page_id = current_page.id 45 self.min = min 46 self.max = max 45 47 46 48 # Get the menu tree dict from the database: … … 52 54 context = { 53 55 "menu": menu_html, 56 "min": min, 57 "max": max 54 58 } 55 self._render_template("main_menu ", context)59 self._render_template("main_menu_ul", context) 56 60 57 61 … … 63 67 64 68 for entry in menu_data: 65 66 69 # Generate the absolute url to the page: 67 70 href = [] … … 73 76 entry["href"] = "/" + href + "/" 74 77 75 if entry.has_key("subitems"): 76 # go recusive deeper into the menu entries 77 entry["submenu"] = self.get_html(entry["subitems"], parent=href) 78 else: 79 entry["submenu"] = "" 78 if (int(entry["level"]) <= self.max or self.max<self.min) and \ 79 int(entry["level"]) >= self.min: 80 80 81 if entry["id"] == self.current_page_id: 82 # Mark the last menu item, the current displayed page 83 entry["is_current"] = True 81 if entry.has_key("subitems"): 82 # go recusive deeper into the menu entries 83 entry["submenu"] = self.get_html( 84 entry["subitems"], parent=href 85 ) 86 else: 87 entry["submenu"] = "" 84 88 85 # Render one menu entry 86 html = self._get_rendered_template("main_menu_li", entry) 87 result.append(html) 89 # Render one menu entry 90 html = self._get_rendered_template("main_menu_li", entry) 91 result.append(html) 92 elif int(entry["level"]) < self.min: 93 if entry.has_key("subitems"): 94 html = self.get_html(entry["subitems"],parent=href) 95 result.append(html) 88 96 89 context = { 90 "menu": mark_safe("\n".join(result)), 91 } 92 93 # render all menu entries into a <ul> tag 94 menu_html = self._get_rendered_template("main_menu_ul", context) 97 if result == []: 98 menu_html = "" 99 else: 100 menu_html = "\n".join(result) 95 101 96 102 return mark_safe(menu_html) 97