Tried it, works great, thanks. (Of course for my purpose i have to check if len(breadcrumbs) == 0.)
On 10/07/2010 07:35 PM, Mikko Ohtamaa wrote: > > > Kees Hink wrote: >> >> * How can i check in my viewlet code if we're actually on the Plone Site? >> The >> self.context of the viewlet is front-page, not the site root. Even >> self.request >> is front-page/document_view >> > > Cheap trick: Check if the length of breadcrumbs is zero. > > class Back(grok.Viewlet): > """ Back button > """ > > def update(self): > context= aq_inner(self.context) > parent = aq_parent(context) > > breadcrumbs_view = getView(self.context, self.request, > 'breadcrumbs_view') > breadcrumbs = breadcrumbs_view.breadcrumbs() > > if (len(breadcrumbs)==1): > self.backTitle = "Home" > else: > if hasattr(parent, "Title"): > self.backTitle = parent.Title() > else: > self.backTitle = _(u"Back") > > self.backUrl = parent.absolute_url() > self.isHome = len(breadcrumbs)==0 > > http://plonegomobile.googlecode.com/svn/trunk/gomobile/gomobiletheme.basic/gomobiletheme/basic/viewlets.py > > Also... breadcrumbs viewlet might provide hints between visual and physical > traversing differences. > > -Mikko > > ----- > Mikko Ohtamaa > mFabrik - Freedom Delivered. > > Web site - http://mfabrik.com > Mobile site - http://mfabrik.mobi > Blog - http://blog.mfabrik.com _______________________________________________ Product-Developers mailing list [email protected] http://lists.plone.org/mailman/listinfo/product-developers
