[Product-Developers] xdv/diazo and if-else/switch conditional structures

Noe Misael Nieto Arroyo noe at iservices.com.mx
Thu Feb 3 23:18:26 UTC 2011


This works like a charm.

Thanks

--
Noe

2011/2/2 Laurence Rowe <l at lrowe.co.uk>

>
>
> Noe Misael Nieto Arroyo wrote:
> >
> > Hi.
> >
> > I'm working with diazo and I want to do some sort of if-then-else
> > structure.
> > But i don't know how to do it.
> >
> > Currently, what I do is this:
> >
> >     <!-- Stuff that happens on all pages -->
> >     <xi:include href="rules-common.xml" />
> >     <!-- Stuff that happens on Plone's Documents -->
> >     <rules css:if-content="body.portaltype-document">
> >       <xi:include href="rules-document.xml" />
> >     </rules>
> >     <!-- Stuff that happens on Plone's Collection Views -->
> >     <rules css:if-content="body.portaltype-topic">
> >       <xi:include href="rules-topic.xml" />
> >     </rules>
> >
> > What I want to do is this:
> >
> > Include rules-common.xml for all pages.
> >
> > If the page is a Plone Document, load rules-document.xml
> > if the page is a Collection view, load rules-topic.xml
> > otherwise, load a rules-generic.xml
> >
> > How can I achieve this on xdv/Diazo?
> >
>
> If/elif/else doesn't really work well with xml - you see the same problem
> with ZPT.
>
> One solution might be to move your tests to xsl variables (remember to
> include the xsl namespace at the top.):
>
> <xsl:variable name="document" css:select="body.portaltype-document"/>
>
> then use the variable like:
>
> <rules if-content="$document">
> ...
> </rules>
> </rules if-content="not($document)">
> ...
> </rules>
>
> I've not actually tried it so I'm not certain it will work, but I should be
> able to fix the compiler if it doesn't. The <xsl:variable> elements will
> need to be in the top level of the rules file (and not xincluded files).
>
> Laurence
> --
> View this message in context:
> http://plone.293351.n2.nabble.com/xdv-diazo-and-if-else-switch-conditional-structures-tp5986122p5987065.html
> Sent from the Product Developers mailing list archive at Nabble.com.
> _______________________________________________
> Product-Developers mailing list
> Product-Developers at lists.plone.org
> https://lists.plone.org/mailman/listinfo/product-developers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.plone.org/pipermail/plone-product-developers/attachments/20110203/44eca1c9/attachment-0002.html>


More information about the Product-Developers mailing list