Search

http://pastie.org/6382819.js

here is the xsl that ships with symphony.

Would someone mind walking me through this?

For example, how would I add a dynamic class name that is also the page name to the li that is rendered? Would I use the position() method?

so the "system" automatically creates the navigation as a section?

http://pastie.org/pastes/6382927/text

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="navigation">
        <ul id="menu">
            <!-- Call the template (create below) for each page that is not hidden or an admin page -->
            <xsl:apply-templates select="page[not(types/type = 'hidden') and not(types/type = 'admin')]"/>
            <!-- If the $is-logged-in param is set... -->
            <xsl:if test="$is-logged-in">
                <!-- Create two static entries -->
                <li><a href="{$root}/drafts/">Drafts</a></li>
                <li><a href="{$root}/symphony/">Admin</a></li>
                <!-- If the user is a developer, add a link to the debug page -->
                <xsl:if test="/data/logged-in-author/author[@user-type = 'developer']">
                    <li><a href="?debug">Debug</a></li>
                </xsl:if>
            </xsl:if>
        </ul>
    </xsl:template>

    <!-- Our templates for each page in the "page" DS -->
    <xsl:template match="page">
        <!-- Add the page handle to the li 'class' attribute -->
        <li class="{@handle}">
            <!-- Create an anchor element, with the root of the site and our page/@handle attribute -->
            <a href="{$root}/{@handle}/">
                <!-- If the handle matches the root page, give our anchor a class of 'active' -->
                <xsl:if test="@handle = $root-page">
                    <xsl:attribute name="class">active</xsl:attribute>
                </xsl:if>
                <!-- Print the page's name -->
                <xsl:value-of select="name"/>
            </a>
        </li>
    </xsl:template>

</xsl:stylesheet>

Perfect, thank you very much!

You're very welcome :)

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