Search

When I create my navigation with Symphony I want to filter on type: I don’t want to display pages with type=hidden. I use the following XSLT for that and it works:

<xsl:for-each select="data/navigation/page[types/type != 'hidden']">

but… When a page has 2 types (for example, 404 AND hidden), it gets shown in my navigation. I guess it’s because my XML is then like this:

<page handle="404" id="88">
    <name>Not found</name>
    <types>
        <type>404</type>
        <type>hidden</type>
    </types>
</page>

Does anyone know what the correct XSLT is to filter on type=hidden when there are more types available?

I’d love to know this as well, as I was under the impression that the above worked!

Think what you are after is more like this:

<xsl:for-each select="data/navigation/page[not(types/type = 'hidden')]">

Your attempt matches if one of the ‘type’ nodes has a string-value that is not equal to ‘hidden’. My example matches if there does not exist a ‘type’ node which has a string-value equal to ‘hidden’. See the difference in logic?

Comparison operators in XPath checks each node in a node-set separately against a number, string or boolean. In this case each ‘type’ node against the string ‘hidden’.

Thanx froded! Your solution does exactly what’s required

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