Search

Hi @ All

I have a new project which is multilingual. So i work with selectbox link etc.. Now i have an output from a ds which represent the navigation. But now i should do nested lists...

my output look like this:

Mainpoints:

  • ...
  • ...
  • ...

Subpoints:

  • ...
  • ...
  • ...

etc.

Here two pasties... http://pastie.org/1957571 http://pastie.org/1957584

At the moment I have no Idea how to Group the subpoints under the mainpoints linke this:

Mainpoints:

  • ... Subpoints
    • ...
    • ...
    • ...
  • ...
  • ...

Thanks for some Tipps..

Untested:

<xsl:template match="data">
    <xsl:apply-templates select="ds-kategorien/kategorie" />
</xsl:template>

<xsl:template match="ds-kategorien/kategorie">
    <ul>
        <xsl:attribute name="class">
            <xsl:choose>
                <xsl:when test="@link-id = ''">
                    <xsl:text>Main_nav</xsl:text>
                <xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="@value" />
                </xsl:otherwise>
            </xsl:choose>
        <xsl:attribute>

        <xsl:apply-templates select="kategorie" />
    </ul>
</xsl:template>

<xsl:template match="kategorie">
    <li>
        <a href="http://muster.muster.ch/de/{titel/@handle}" title="{titel}">
            <xsl:value-of select="titel" />
        </a>
    </li>
</xsl:template>

My solution, again without having tested it:

<xsl:template match="kategorie">
    <ul>
        <xsl:apply-templates select="entry" />
    </ul>
</xsl:template>

<xsl:template match="kategorie/entry">
    <li>
        <xsl:value-of select="titel" />
        <xsl:apply-templates select="../../kategorie[@link-id = current()/@id]" />
    </li>
</xsl:template>

Start the thing using

<xsl:apply-templates select="kategorie[@link-id='']" />

Hey phoque

That was exactly what i want! Thanks so much...

"kategorie[@link-id = current()/@id]" was the search expression but can you explain, that this thing exactly do?

thanks much!

Phoque, that is elegant. I like it.

Hi together

So little question

I have this template:

  <xsl:template match="data/ds-kategorien/kategorie/entry">
    <li>
<xsl:choose>
        <xsl:when test="kategorie/item/@handle = ''">
        <a href="{$root}/{$url-language}/{titel/@handle}/"><xsl:value-of select="titel"/></a>
    </xsl:when>
    <xsl:otherwise>
        <a href="{$root}/{$url-language}/{kategorie/item/@handle}/{titel/@handle}/"><xsl:value-of select="titel"/></a>
    </xsl:otherwise>
</xsl:choose>
        <xsl:apply-templates select="../../kategorie[@link-id = current()/@id]" />

    </li>
</xsl:template>

what i want to do is, two different link types. But it does not recognize my test… .

If i put the expression into

<xsl:value-of select="kategorie/item/@handle"/>

i have some output what is wrong?

Try <xsl:when test="kategorie/item[@handle = '']"> which will return boolean.

As for your earlier question, kategorie[@link-id = current()/@id].

current() is used to refer to the context of the template, in this case entry. Without current() the search tries to match the attribute @link-id with @id of the kategorie element, which won't get your desired result :)

Hi @all

This is the output:

<li> 
<a href="http://muster.muster.ch/fr//ueber-uns/">ÜBER UNS</a> 
<ul> 
  <li> 
    <a href="http://muster.muster.ch/fr/ueber-uns/kodex/">Kodex</a> 
  </li> 
  <li> 
    <a href="http://muster.muster.ch/fr/ueber-uns/aufgaben/">Aufgaben</a> 
  </li> 
  <li> 
    <a href="http://muster.muster.ch/fr/ueber-uns/ziele/">Ziele</a> 
  </li> 
  <li> 
    <a href="http://muster.muster.ch/fr/ueber-uns/wer-wir-sind/">Wer wir sind</a> 
  </li> 
</ul> 

And that's the template for the output:

<xsl:template match="/">

<xsl:apply-templates select="data/ds-kategorien/kategorie[@link-id='']" />

</xsl:template>


<xsl:template match="data/ds-kategorien/kategorie">
    <ul>
        <xsl:apply-templates select="entry" />
    </ul>
</xsl:template>

<xsl:template match="data/ds-kategorien/kategorie/entry">
    <li>

<xsl:choose>
        <xsl:when test="kategorie/item[@handle = '']">
        <a href="{$root}/{$url-language}/{titel/@handle}/"><xsl:value-of select="titel"/></a>
    </xsl:when>
    <xsl:otherwise>
        <a href="{$root}/{$url-language}/{kategorie/item/@handle}/{titel/@handle}/"><xsl:value-of select="titel"/></a>
    </xsl:otherwise>
</xsl:choose>
        <xsl:apply-templates select="../../kategorie[@link-id = current()/@id]" />

    </li>
</xsl:template>

I know that the problem with the two // is in this expression

<a href="{$root}/{$url-language}/{kategorie/item/@handle}/{titel/@handle}/"><xsl:value-of select="titel"/></a>

but how can i change this? the result shoud be

<li> 
<a href="http://muster.muster.ch/fr/ueber-uns/">ÜBER UNS</a> 
<ul> 
  <li> 
    <a href="http://muster.muster.ch/fr/ueber-uns/kodex/">Kodex</a> 
  </li> 
  <li> 
    <a href="http://muster.muster.ch/fr/ueber-uns/aufgaben/">Aufgaben</a> 
  </li> 
  <li> 
    <a href="http://muster.muster.ch/fr/ueber-uns/ziele/">Ziele</a> 
  </li> 
  <li> 
    <a href="http://muster.muster.ch/fr/ueber-uns/wer-wir-sind/">Wer wir sind</a> 
  </li> 
</ul> 

has anyone an idea?

Now it works well. Here is my template for category-navigation with nested categories and one DS with select-box link.

Thanks to brendo and vladG

<xsl:apply-templates select="ds-kategorien/elternelement[@link-id='']" />


<xsl:template match="ds-kategorien/elternelement">
    <ul>
        <xsl:apply-templates select="entry" />
    </ul>
</xsl:template>

<xsl:template match="ds-kategorien/elternelement/entry">
    <li>
     <a>
        <xsl:attribute name="href">
            <xsl:value-of select="/data/params/root" />
            <xsl:text>/</xsl:text>
            <xsl:value-of select="/data/params/url-language" />
            <xsl:text>/</xsl:text>
            <xsl:value-of select="/data/params/current-page" />
            <xsl:text>/</xsl:text>
            <xsl:apply-templates select="elternelement" mode="search-url" />
            <xsl:value-of select="name/@handle" />
        </xsl:attribute>
        <xsl:value-of select="name"/>
     </a>
        <xsl:apply-templates select="//elternelement[@link-id = current()/@id]"/>
    </li>
</xsl:template>


<xsl:template match="elternelement" mode="search-url">
    <xsl:apply-templates select="parent::elternelement" mode="search-url" />
    <xsl:value-of select="concat(item/@handle,'/')" />
</xsl:template>

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