I have one layout component for all my pages, I want to switch this component based on the user desire. I don't want to add a property to each page to return the current layout component.
+1
A:
Assuming you have a fixed number of layouts, you can use blocks. Your layout.tml would look something like:
<t:delegate to="layout"/>
<t:block id="layout1">
<body>...</body>
</t:block>
<t:block id="layout2">
<body>...</body>
</t:block>
Your layout.java would have:
public Object getLayout() {
if (...) {
return _layout1;
} else {
return _layout2;
}
}
@Inject
private Block _layout1;
@Inject
private Block _layout2;
Brian Deterling
2009-09-12 16:11:03
Great,But I don't want to put all the layouts in one .tml file..Is there a way to delegate to a component???
Bahaa Zaid
2009-09-14 00:22:58
Yes, the target of delegate can be a block or a component. So you could just define a component for each layout you need. I think you'd still need to list all those components in the main layout.tml but the html could be in the individual components.
Brian Deterling
2009-09-15 16:02:12
A:
Hello
It is possible to give a default value for the t:delegate block after loading the page?
alan earl
2009-11-11 08:23:30