0 users online. Create an account or sign in to join them.Users

Search

Just to be safe, I prefer to use root links starting with / and apply the template if the condition is met:

<xsl:template match="img/@src[starts-with(.,'/')]" mode="html">
    <xsl:attribute name="{name()}">
        <xsl:value-of select="concat($root, .)" />
    </xsl:attribute>
</xsl:template>

Thanks!

This thread sure is usefull.

Not directly live-changing and more symphony centric:

I needed a convenient way to handle a nested page navigation that lists entries instead of subpages. So, for each section whose entries should appear as sub navigation item, create a DS that follows a strict naming convention. Let's say you have a page called "projects" then you'd might name it TOC Projects. Choose the field that's representing your url parameter handle (e.g. a field called name) for Parameter Output and uncheck paginate results since you want all entries to appear in your ds-toc-projects parameter.

Now the xslt (apply it to your navigation DS):

<xsl:template match="page">
    <xsl:variable name="subname">
        <xsl:value-of select="concat('/data/params/ds-toc-', @handle)"/>
    </xsl:variable>
    <li>
        <a href="{$root}/{$lang}/{@handle}/" class="xhr"><xsl:value-of select="item"/></a>
        <xsl:if test="dyn:evaluate($subname)">
            <xsl:apply-templates select="dyn:evaluate($subname)" mode="sub">
                <xsl:with-param name="parent" select="@handle"/>
            </xsl:apply-templates>
        </xsl:if>

    </li>
</xsl:template>

    <xsl:template match="*" mode="sub">
    <xsl:param name="parent"/>
    <ul class="sub clear">
        <xsl:for-each select="item">
            <li>
                <a href="{$root}/{$lang}/{$parent}/{@handle}/" class="xhr"><xsl:value-of select="."/>
                </a>
            </li>
        </xsl:for-each>

    </ul>
</xsl:template>

Since xpath-expressions can't be created at runtime you'll need a exsl extension called dyn:evaluate. So your template header would look something like this:

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

@iwyg, where does page <xsl:template match="page"> came from?

From a navigation datasource probably. If I'm not mistaken, it's the PLH variation :)

@vladG, yep. PLH?

Yeah,PLH? What's that then?

Page LHandles extension. You have it installed. Recognized from your code.

oh, yes. indeed.

Nice, will it be possible to post another code where Page LHandles is not installed?

sure, obmit the $lang variable and you're good. Instead of {$root}/{$lang}/{@handle} it'd be {$root}/{@handle}, though I'm not 100% sure if @handle represents the page-handle on a regular Navigation DS

[edit] To complete confusion: {$lang} is not a regular parameter. The real parameter is $url-language. In this case, I created this variable to ensure theres a default language string in case $url-language is not present. So, never use $lang without declaring it before :)

Okie, to clarify it further. The code will be insert in 'project.xsl' and datasource for 'Project' page will be 'Navigation' and 'TOC Project'?

Cool. Got it work!

I normally tend to include page-navigation stylesheets in my master stylesheet.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.2 or above
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.0 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details