Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Stipo 11 posts 31 karma points
    Oct 06, 2010 @ 21:27
    Stipo
    0

    Problem with Navigation

    Hi guys,

    sorry for my bad english, but i want to learn it. I hope it can be read.

    My problem is, that my XSLT Code never comes in the second Tree. I commentated the code section, that does not function. I use Umbraco 4.5.2.

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [
        <!ENTITY nbsp "&#x00A0;">
    ]>
    <xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxml="urn:schemas-microsoft-com:xslt"
      xmlns:umbraco.library="urn:umbraco.library"
      exclude-result-prefixes="msxml umbraco.library">
        <xsl:output method="xml" omit-xml-declaration="yes" />
        <xsl:param name="currentPage"/>
        <!-- Input the documenttype you want here -->
        <xsl:param name="startLevel" select="2"/>

        <xsl:template match="/">
          <xsl:if test="count($currentPage/ancestor-or-self::* [@level = $startLevel]/*) &gt; 0">
            <div class="menu">
       <ul>
          <xsl:for-each select="$currentPage/ancestor-or-self::* [@level = $startLevel]/* [string(umbracoNaviHide) != '1' and @isDoc]">
                      <xsl:call-template name ="drawNode">
         <xsl:with-param name="level" select="1"/>
      </xsl:call-template>
                  </xsl:for-each>
               </ul>
            </div>
          </xsl:if>
        </xsl:template>

        <xsl:template name="drawNode">
          <xsl:param name="level"/>
          <li>
          <xsl:choose>
      <xsl:when test="@id=$currentPage/@id">
        <strong><xsl:value-of select="@nodeName"/></strong>
      </xsl:when>
      <xsl:otherwise>
                 <a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a>
      </xsl:otherwise> 
          </xsl:choose>
          <!-- This IF does not function -->
          <xsl:if test="count($currentPage/descendant-or-self::node [@id=$currentPage/@id]) &gt; 0">
          <!-- this range is not called -->
          <ul class="subItems">
      <xsl:for-each select="node">
         <xsl:call-template name="drawNode">
            <xsl:with-param name="level" select="number($level)+1"/>
                         </xsl:call-template>
      </xsl:for-each>
      </ul>
                      <!-- this range is not called -->
                   </xsl:if>
          </li>
        </xsl:template>

    <xsl:template name="newDrawNode">
      <xsl:param name="parent"/>
     
    </xsl:template>

    </xsl:stylesheet>

    thanks for help.

    Stephan

  • Jeff Grine 149 posts 189 karma points
    Oct 06, 2010 @ 21:40
    Jeff Grine
    0

    Looks like a mix of the old and new xml schemas? In the new, elements are named after the document type instead of all being named 'node'. So you'd want descendant-or-self::* in your test.

  • Stipo 11 posts 31 karma points
    Oct 06, 2010 @ 22:06
    Stipo
    0

    Can you write a code example? It is my first XSLT Code, that i write. I not understand, what you speak about 'node'.

    I have edit my code.

    <xsl:if test="count($currentPage/descendant-or-self::* [@id=$currentPage/@id]) &gt; 0">

    But it not work.

    Thanks Stephan

  • eddy 43 posts 64 karma points
    Oct 07, 2010 @ 10:28
    eddy
    0

    I had this problem too when I started learning a few weeks ago. There was a change in Umbraco which meant that when I was trying some XSLT from the Umbraco books or Umbraco TV the examples would not work. Take a look at my post where Ismail and Morten pointed me in the right direction.

    Eddy

  • Stipo 11 posts 31 karma points
    Oct 07, 2010 @ 21:44
    Stipo
    0

    Hallo zusammen,

    ich bin mal so frech und antworte auf Deutsch, denn das behersche ich, was ich von meinem Englisch nicht behaupten kann.

    @Eddy, danke erstmal für den Link und den Tip. Aber leider hat der mich nicht sehr viel weiter gebracht, da ich zwar mal die Grundlagen zu XSLT aus einem Buch gelesen habe, aber bis jetzt noch nie richtig eingesetzt hatte. Daher hab ich auch keinerlei erfahrung mit XSLT und wie ich den Code aufbauen muss.
    Dann kommt eben erschwerend hinzu, das mein Englisch mehr schlecht als recht ist, und man aber leider Hilfe bei Umbraco nur in Englisch findet.

    Wenn mir eben einer mal die eine Zeile Code schreiben könnte, wie die sein muss, das die mit Umbraco 4.5.2 funktioniert würde es mir sehr helfen, da ich auch aus bestehendem Code lernen kann.

    Ich erwarte ja von keinem, das er mir eine "alles umfassende" Lösung ausarbeiten muss, sondern nur, wie ich diesen gewissen Teil schreiben muss, das die IF Prüfung mit True ausfällt.

    Hoffe nun, das mir das keiner krumm nimmt, wenn ich hier so frech in Deutsch schreibe. Aber ich würde schon gerne Umbraco intensiver erlernen, da ich das CMS als perfekt ansehe.

    Grüße Stephan

  • Jeff Grine 149 posts 189 karma points
    Oct 07, 2010 @ 22:06
    Jeff Grine
    0

    Stephan - one of the problems with xslt is that it's tough to troubleshoot without the xml you're running it against. Could be that you just don't have any nodes that match the condition? Have you tried debugging the xslt? That gives you the opportunity to see what you've got in certain variables and run different xpath queries as watches to what results you get. You might also try just listing out the node ids that the xpath gives you to see what it is pulling back. Something like

    <xsl:for-each select="$currentPage/descendant-or-self::*" />
    <xsl:value-of select="@id"/>
    </xsl:for-each>

    Then if the id of the current page is not in that list, that will give you something to go on.

    Hang in there.

    Jeff

    (Hope you can understand my English - my German is no doubt worse than your English.)

  • Stipo 11 posts 31 karma points
    Oct 08, 2010 @ 01:25
    Stipo
    0

    I understand you, but any words not. Your info ist good. I must see, i can debug the Code. I am learning by doing, then the Error help me, to understand it. I learn very by debugging any code under C#. Thanks for this Info, that XSLT can debug.

    I understand, that the first condition not function, and then this condition can not match.
    Babelfish help me, write English, but that is not the best tool. I write in english, then translate with babelfish to german. I hope, that can learn english better. Hope you can understand this english.

    Can you request me, that you can read my english.

    Regards
    Stephan

Please Sign in or register to post replies

Write your reply to:

Draft