On 9/13/06, Matthew Bevan <[EMAIL PROTECTED]> wrote:
>
> Howdy!
>
> I'm trying to (ab)use Widgets to perform simple Portlet tasks such as
> side-bar menus, calendars, etc. So far, it's working exceptionally well.
> However, I need to provide conditional Portlets. For example, I want an
> additional menu to appear if signed in as an administrator. Etc.
>
> Any idea how I can tell a widget to not render, even if asked?
I'm doing exactly the same thing. I've gone the route of highly
generalising it for the moment and using a function that returns left
and right nav portlets based on which page you are on.
A cut down example is:
def getPortlets(page):
left_portlet_list = [(nav_portlet,(),{'page':page})]
right_portlet_list = []
if "editor" in identity.current.groups:
right_portlet_list.append((editor_portlet,(),{'page':page}))
return dict(left=left_portlet_list, right=right_portlet_list)
It recieves a page object and returns a dictionary of lists of portlet
tuples that contain a portlet instance, a tuple of args and a dict of
kwargs.
Then in the template I use:
<div py:def="leftcol" id="leftcol">
<div py:for="(portlet, args, kwargs) in portlets['left']"
py:replace="portlet.display(*args, **kwargs)">
</div>
</div>
<div py:def="rightcol" id="rightcol">
<div py:for="(portlet, args, kwargs) in portlets['right']"
py:replace="portlet.display(*args, **kwargs)">
</div>
</div>
This displays each portlet in the list sending it any args and kwargs.
Hope it's of some use or provides ideas. I'm creating a highly
generalised cms that I'll release in November under a very liberal
license. If it might be of use to you before then, let me know and
I'll send you what code I've got so far.
Ed
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---