Re: Override-layout for Silva 2.1
"Luthiger Stoll Benno" <[email protected]> Wed, 9 Dec 2009 14:32:11 +0100
| Newsgroups | gmane.comp.web.zope.silva.devel |
|---|---|
| Message-ID | <[email protected]> |
Dear Kit
Eventually I've decided to provide a special content object MyIndex (and
MyIndexVersion) which extends SilvaDocument. Because this content type is
'dumb', the module is very compact.
However, there's quite some boilerplate in the views directory (and some
additions in the install script).
Now I can replace the root container's index document (and its language
versions) by MyIndex objects and, after specifying the zcml directive:
---
<browser:page
name="index.html"
for=".content.MyContent.MyIndex"
class="Products.SilvaLayout.browser.silvaview.Content"
template="templates/override.pt"
permission="zope2.View"
layer=".browser.skin.IMySkin"
/>
---
I get the content displayed in the desired layout.
Benno
-----Original Message-----
From: Kit BLAKE [mailto:[email protected]]
Sent: Dienstag, 8. Dezember 2009 18:04
To: Luthiger Stoll Benno
Cc: Sylvain Viollon; Silva Developer
Subject: Re: [silva-dev] Override-layout for Silva 2.1
Benno,
We don't know David's hint, that was UCL invention. Quite clever, and
we've been looking for an opportunity to try it out. But I'm not sure
how it'll work in a multilingual situation. David, any ideas?
Kit
ps: This still doesn't answer your question, but we'll investigate.
On 4 Dec 2009, at 11:14, Luthiger Stoll Benno wrote:
> Dear Sylvain
>
> Your hint works, but doesn't solve my problem ;-(
>
> My problem is not when the user calls the container but one of the
> language
> versions of the index file.
> The overrideLayout is correctly used when mySiteRoot/ is called.
> But the overrideLayout should also be used when the user calls
> mySiteRoot/index of mySiteRoot/index_EN.
>
> Do I have to create a class TranslatedIndex (deriving from
> SilvaDocument)
> for that I can define a ZCML directive like:
>
> <browser:page
> name="index.html"
> for=".myClasses.TranslatedIndex"
> class=" Products.SilvaLayout.browser.silvaview.Content "
> template="override.pt"
> permission="zope2.View"
> layer=".skin.IYourLayer"
> />
>
> Or is David's hint preferable?
>
> Benno
>
>
> -----Original Message-----
> From: Sylvain Viollon [mailto:[email protected]]
> Sent: Freitag, 4. Dezember 2009 10:00
> To: Luthiger Stoll Benno
> Cc: Silva Developer
> Subject: Re: [silva-dev] Override-layout for Silva 2.1
>
> On Fri, 4 Dec 2009 09:29:19 +0100
> "Luthiger Stoll Benno" <[email protected]> wrote:
>
>> Hello all
>>
>
> Hello,
>
>> Is there no more help available from the infrae pros concerning my
>> question? Just a little tip, maybe.
>>
>
> I didn't tried it, but I think this should work:
>
> 1. Create a python class, on the filesystem, in a py file (let's
> called it views.py) for your container:
>
> from Products.SilvaLayout.browser.silvaviews import Container
>
> class TranslatedContainer(Container):
>
> def context_or_default(self):
> # 1. figure out the language.
> language = self.request.cookies.get('silva_language', 'en')
> language = language.upper()
> container = self.context.aq_inner
> # 2. Lookup the index document
> index = getattr(container, 'index_' + language, None)
> if index is None:
> # Try to fallback to default silva index documents
> index = getattr(container, 'index', None)
> return index
>
>
> 2. After in your ZCML, when you declare the 'container' template,
> use your new class:
>
> <browser:page
> name="index.html"
> for="Products.Silva.interfaces.IContainer"
> class=".views.TranslatedContainer"
> template="maintemplate.pt"
> permission="zope2.View"
> layer=".skin.IYourLayer"
> />
>
> Of course we assumed here that the python file views.py is in the
> same directory than the configure.zcml file.
>
>
> 3. Restart,
>
>
> Regards,
>
> Sylvain,
>
>
> Note: SilvaLayout is deprecated in favor of silva.core.layout. It will
> still exists in 2.2, but will be removed one day.
>
> --
> Sylvain Viollon -- Infrae
> t +31 10 243 7051 -- http://infrae.com
> Hoevestraat 10 3033GC Rotterdam -- The Netherlands
> _______________________________________________
> silva-dev mailing list
> silva-dev-IAPFreCvJWM6s/[email protected]
> https://lists.infrae.com/mailman/listinfo/silva-dev
_______________________________________________
silva-dev mailing list
silva-dev-IAPFreCvJWM6s/[email protected]
https://lists.infrae.com/mailman/listinfo/silva-dev
smime.p7s
(application/x-pkcs7-signature, 3.9 KB) - not displayed