Search

So...

I have this nice piece of code which is supposed to hide menu items that don't belong to the current language.

<xsl:template match="navigation">
    <ul id="menu">
        <xsl:apply-templates select="page[not(types/type = 'hidden' or types/type != $language )]"/>
    </ul>
</xsl:template>

And this is XML I have that is providing navigation info:

<navigation>
    <page handle="en" id="1">
        <name>Home</name>
        <types>
            <type>en</type>
            <type>index</type>
        </types>
    </page>
    <page handle="he" id="2">
        <name>Home HE</name>
        <types>
            <type>he</type>
        </types>
    </page>
    <page handle="about" id="3">
        <name>About</name>
        <types>
            <type>en</type>
        </types>
    </page>
</navigation>

Home HE should be hidden when $language is en, while Home and About are supposed to be visible.

About page is visible, and Home is not. I'm guessing that is because besides en, Home also has index attribute.

So, how should I make that statement to filter out those results properly?

Figured it out. This is appropreate incantation:

<xsl:apply-templates select="page[types/type != 'hidden' and types/type = $language]"/>

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details