use 'instanceName' attribute for controlling layout instances
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@2994 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
6b62e383ac
commit
330f15e634
2 changed files with 25 additions and 26 deletions
|
@ -42,32 +42,6 @@ class LayoutNode(Node):
|
||||||
|
|
||||||
class NodeLayoutInstance(LayoutInstance):
|
class NodeLayoutInstance(LayoutInstance):
|
||||||
|
|
||||||
def getLayouts(self, region):
|
|
||||||
""" Return sublayout instances.
|
|
||||||
"""
|
|
||||||
if region is None:
|
|
||||||
return []
|
|
||||||
result = []
|
|
||||||
sublayouts = self.template.sublayouts
|
|
||||||
if sublayouts is not None: # hard-coded sublayouts
|
|
||||||
for l in region.layouts:
|
|
||||||
if sublayouts is None or l.name in sublayouts:
|
|
||||||
li = ILayoutInstance(self.context)
|
|
||||||
li.template = l
|
|
||||||
result.append(li)
|
|
||||||
return result
|
|
||||||
# sublayouts specified via subnodes of the current menu node
|
|
||||||
menu = self.context.getMenu()
|
|
||||||
subnodes = menu.getMenuItems()
|
|
||||||
names = region.layouts.keys()
|
|
||||||
for n in subnodes:
|
|
||||||
if n.viewName in names:
|
|
||||||
layout = region.layouts[n.viewName]
|
|
||||||
li = ILayoutInstance(n)
|
|
||||||
li.template = layout
|
|
||||||
result.append(li)
|
|
||||||
return result
|
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def targetView(self):
|
def targetView(self):
|
||||||
request = self.view.request
|
request = self.view.request
|
||||||
|
@ -76,3 +50,23 @@ class NodeLayoutInstance(LayoutInstance):
|
||||||
view.node = self.context
|
view.node = self.context
|
||||||
return view
|
return view
|
||||||
|
|
||||||
|
|
||||||
|
class NavigationNodeLayoutInstance(NodeLayoutInstance):
|
||||||
|
|
||||||
|
def getLayouts(self, region):
|
||||||
|
""" Return sublayout instances specified via subnodes of the current menu node.
|
||||||
|
"""
|
||||||
|
if region is None:
|
||||||
|
return []
|
||||||
|
result = []
|
||||||
|
menu = self.context.getMenu()
|
||||||
|
subnodes = menu.getMenuItems()
|
||||||
|
names = region.layouts.keys()
|
||||||
|
for n in subnodes:
|
||||||
|
if n.viewName in names:
|
||||||
|
layout = region.layouts[n.viewName]
|
||||||
|
li = component.getAdapter(n, ILayoutInstance,
|
||||||
|
name=layout.instanceName)
|
||||||
|
li.template = layout
|
||||||
|
result.append(li)
|
||||||
|
return result
|
||||||
|
|
|
@ -20,6 +20,11 @@
|
||||||
for="loops.layout.interfaces.ILayoutNode"
|
for="loops.layout.interfaces.ILayoutNode"
|
||||||
factory="loops.layout.base.NodeLayoutInstance" />
|
factory="loops.layout.base.NodeLayoutInstance" />
|
||||||
|
|
||||||
|
<zope:adapter
|
||||||
|
for="loops.layout.interfaces.ILayoutNode"
|
||||||
|
name="navigation"
|
||||||
|
factory="loops.layout.base.NavigationNodeLayoutInstance" />
|
||||||
|
|
||||||
<include package=".browser" />
|
<include package=".browser" />
|
||||||
|
|
||||||
</configure>
|
</configure>
|
||||||
|
|
Loading…
Add table
Reference in a new issue