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
-- 
View this message in context: 
http://plone.293351.n2.nabble.com/restrict-viewlet-to-site-root-even-if-item-is-default-view-tp5611184p5612297.html
Sent from the Product Developers mailing list archive at Nabble.com.
_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers

Reply via email to