Copied to clipboard

Flag this post as spam?

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


  • Niels 63 posts 119 karma points
    Oct 03, 2011 @ 15:00
    Niels
    0

    Numbering nodes for slideshow

    I'm working on a jscript slideshow, but I want to add a number on each picture. 

    How can I get a number for each slide so I can make a navigation. For each slide a node is created, where the data. The xslt is as follows:

    <div id="slider">
      <div id="mask-gallery">
        <ul id="gallery">
          <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']">
            <li>
              <xsl:if test="afbeeldingSlide > 0">
                <xsl:variable name="mediaNode" select="umbraco.library:GetMedia(afbeeldingSlide, 0)" />
                <xsl:if test="$mediaNode/umbracoFile">
                  <img src="{$mediaNode/umbracoFile}" height="{$mediaNode/umbracoHeight}" width="{$mediaNode/umbracoWidth}" />
                </xsl:if>
              </xsl:if>
            </li>
          </xsl:for-each>
        </ul>
        </div>
      <div id="mask-excerpt">
        <ul id="excerpt">
          <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']">
            <xsl:if test="tekstSlide != ''">
              <li>
                <h1>
                  <xsl:value-of select="(tekstSlide)" disable-output-escaping="yes"/>
                </h1>
                <xsl:if test="string(linkNaarPaginaSlide) != ''">  
                  <a href="{umbraco.library:NiceUrl(linkNaarPaginaSlide)}" id="slidebtn" title="{knoptekstSlide}">
                    <div class="btn-linkslideleft">&nbsp;</div>
                    <div class="btn-linkslidecenter"><xsl:value-of select="(knoptekstSlide)" disable-output-escaping="yes"/></div>
                    <div class="btn-linkslideright">&nbsp;</div>
                  </a>
                </xsl:if>
              </li>
            </xsl:if>
          </xsl:for-each>
        </ul>
      </div>  
    </div>
    <div id="slidenav">
        <a href="#" id="btn-prev"><img src="/images/navslide-left.png" title="Vorige" /></a>
        <a href="#" id="btn-next"><img src="/images/navslide-right.png" title="Volgende" /></a>
    </div>

    I tried the following thing, but no succes... Please help me on this one

    <div id="pagingnav">
      <xsl:variable name="allNodes" select="umbraco.library:GetXmlNodeById(1126)" />
      <xsl:variable name="numbOfNodes" select="count"/>
      <xsl:for-each select="($numbOfNodes)">
       <xsl:variable name="thisNum" select="text()" />
       <xsl:variable name="thisNode" select="$allNodes[position() = $thisNum]" />
        <a href="#" rel="item{thisNode}"><xsl:value-of select="(thisNode)" disable-output-escaping="yes"/></a>
      </xsl:for-each>
    </div>
  • Nigel Wilson 945 posts 2077 karma points
    Oct 03, 2011 @ 23:19
    Nigel Wilson
    0

    Hey

    Replace

    <ahref="#"rel="item{thisNode}"><xsl:value-ofselect="(thisNode)"disable-output-escaping="yes"/></a>

    with

    <ahref="#"rel="item{$thisNode}"><xsl:value-ofselect="($thisNode)"disable-output-escaping="yes"/></a>

    The sneaky little dollar sign is missing...

    Cheers

    Nigel

  • Niels 63 posts 119 karma points
    Oct 04, 2011 @ 09:24
    Niels
    0

    Thanks Nigel, that was some code I missed, but that doesn't do the trick. 

    I know that it have something to do with this line:

    <xsl:variablename="numbOfNodes"select="count"/>

    That must be something like this:

    <xsl:variablename="numbOfNodes"select="count($allNodes)"/>

    But then I get the following error:

    System.Xml.Xsl.XslLoadException: Expression must evaluate to a node-set.

     

     

  • Fuji Kusaka 2203 posts 4220 karma points
    Oct 04, 2011 @ 10:04
    Fuji Kusaka
    0

    Hi Niels,

    May be you could try something like

    <divid="pagingnav">
      <xsl:variablename="allNodes"select="umbraco.library:GetXmlNodeById(1126)"/> 
      <xsl:for-eachselect="$allNodes">
       <a href="#">
          
             <xsl:attribute name="rel">
               <xsl:value-of select="position()" />
             </xsl:attribute>     
              <xsl:value-of select="position()" />
        </a>

      </xsl:for-each>
    </div>

     


  • Niels 63 posts 119 karma points
    Oct 04, 2011 @ 10:28
    Niels
    0

    Hi Fuji, It returned a number but only one (there are 4 childnodes). So i guess that only the parent node gets a number. I tried to fix it with:

    <xsl:variablename="allNodes"select="umbraco.library:GetXmlNodeById(1126)/node"/>

    But it didn't worked.

  • Fuji Kusaka 2203 posts 4220 karma points
    Oct 04, 2011 @ 10:37
    Fuji Kusaka
    0

    Hi Niels,

    If am not wrong you are already picking your source id where you are displaying your nodeName and Url right?

    So i guess you could just leave it like this

    <xsl:variable name="allNodes" select="umbraco.library:GetXmlNodeById($source)"/>  
      <xsl:for-each select="$allNodes">
       <ahref="#">
         
             <xsl:attributename="rel">
               <xsl:value-ofselect="position()"/>
             </xsl:attribute>    
              <xsl:value-ofselect="position()"/>
        </a>

      </xsl:for-each>


  • Niels 63 posts 119 karma points
    Oct 04, 2011 @ 10:50
    Niels
    0

    Yes, thats true, but it only returns this:

    <a rel="1" href="#">1</a>

    But there are 4 subnodes/childs. But there not showing. I would like to see the following output:

     

    <a rel="1" href="#">1</a>
    <a rel="2" href="#">2</a>
    <a rel="3" href="#">3</a>
    <a rel="4" href="#">4</a> 

     

  • Fuji Kusaka 2203 posts 4220 karma points
    Oct 04, 2011 @ 11:06
    Fuji Kusaka
    0

    Niels can you show us your full xslt code?

  • Niels 63 posts 119 karma points
    Oct 04, 2011 @ 11:12
    Niels
    0
    <?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" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">

    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>
        
    <xsl:variable name="source" select="/macro/source"/>

    <xsl:template match="/">

    <!-- The fun starts here -->
    <div id="slider">
      <div id="mask-gallery">
        <ul id="gallery">
          <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']">
            <li>
              <xsl:if test="afbeeldingSlide > 0">
                <xsl:variable name="mediaNode" select="umbraco.library:GetMedia(afbeeldingSlide, 0)" />
                <xsl:if test="$mediaNode/umbracoFile">
                  <img src="{$mediaNode/umbracoFile}" height="{$mediaNode/umbracoHeight}" width="{$mediaNode/umbracoWidth}" />
                </xsl:if>
              </xsl:if>
            </li>
          </xsl:for-each>
        </ul>
        </div>
      <div id="mask-excerpt">
        <ul id="excerpt">
          <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']">
            <xsl:if test="tekstSlide != ''">
              <li>
                <h1>
                  <xsl:value-of select="(tekstSlide)" disable-output-escaping="yes"/>
                </h1>
                <xsl:if test="string(linkNaarPaginaSlide) != ''">  
                  <a href="{umbraco.library:NiceUrl(linkNaarPaginaSlide)}" id="slidebtn" title="{knoptekstSlide}">
                    <div class="btn-linkslideleft">&nbsp;</div>
                    <div class="btn-linkslidecenter"><xsl:value-of select="(knoptekstSlide)" disable-output-escaping="yes"/></div>
                    <div class="btn-linkslideright">&nbsp;</div>
                  </a>
                </xsl:if>
              </li>
            </xsl:if>
          </xsl:for-each>
        </ul>
      </div>  
    </div>
    <div id="slidenav">
        <a href="#" id="btn-prev"><img src="/images/navslide-left.png" title="Vorige" /></a>
        <a href="#" id="btn-next"><img src="/images/navslide-right.png" title="Volgende" /></a>
    </div>
    <div id="links">
    <xsl:variable name="allNodes" select="umbraco.library:GetXmlNodeById($source)"/>  
      <xsl:for-each select="$allNodes">
       <a href="#">
          
             <xsl:attribute name="rel">
               <xsl:value-of select="position()"/>
             </xsl:attribute>     
              <xsl:value-of select="position()"/>
        </a>
      </xsl:for-each>
    </div>
      
    </xsl:template>

    </xsl:stylesheet>
  • Fuji Kusaka 2203 posts 4220 karma points
    Oct 04, 2011 @ 11:23
    Fuji Kusaka
    0

    Can you try this

     

    <xsl:variablename="source"select="/macro/source"/>
    <xsl:variablename="allNodes"select="umbraco.library:GetXmlNodeById($source)"/>  
    <xsl:templatematch="/">

    <!-- The fun starts here -->
    <divid="slider">
      <divid="mask-gallery">
        <ulid="gallery">
          <xsl:for-eachselect="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']">
            <li>
              <xsl:iftest="afbeeldingSlide > 0">
                <xsl:variablename="mediaNode"select="umbraco.library:GetMedia(afbeeldingSlide, 0)"/>
                <xsl:iftest="$mediaNode/umbracoFile">
                  <imgsrc="{$mediaNode/umbracoFile}"height="{$mediaNode/umbracoHeight}"width="{$mediaNode/umbracoWidth}"/>
                </xsl:if>
              </xsl:if>
            </li>
          </xsl:for-each>
        </ul>
        </div>
      <divid="mask-excerpt">
        <ulid="excerpt">
          <xsl:for-eachselect="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']">
            <xsl:iftest="tekstSlide != ''">
              <li>
                <h1>
                  <xsl:value-ofselect="(tekstSlide)"disable-output-escaping="yes"/>
                </h1>
                <xsl:iftest="string(linkNaarPaginaSlide) != ''">  
                  <ahref="{umbraco.library:NiceUrl(linkNaarPaginaSlide)}"id="slidebtn"title="{knoptekstSlide}">
                    <divclass="btn-linkslideleft"></div>
                    <divclass="btn-linkslidecenter"><xsl:value-ofselect="(knoptekstSlide)"disable-output-escaping="yes"/></div>
                    <divclass="btn-linkslideright"></div>
                  </a>
                </xsl:if>
              </li>
            </xsl:if>
          </xsl:for-each>
        </ul>
      </div>  
    </div>
    <divid="slidenav">
        <ahref="#"id="btn-prev"><imgsrc="/images/navslide-left.png"title="Vorige"/></a>
        <ahref="#"id="btn-next"><imgsrc="/images/navslide-right.png"title="Volgende"/></a>
    </div>
    <divid="links">

      <xsl:for-eachselect="$allNodes">
       <ahref="#">     
             <xsl:attributename="rel">
               <xsl:value-ofselect="position()"/>
             </xsl:attribute>    
              <xsl:value-ofselect="position()"/>
        </a>
      </xsl:for-each>


    </div>
     
    </xsl:template>

     

  • Niels 63 posts 119 karma points
    Oct 04, 2011 @ 13:35
    Niels
    0

    Still the only output I get is:

    <arel="1"href="#">1</a>
  • Fuji Kusaka 2203 posts 4220 karma points
    Oct 04, 2011 @ 13:48
    Fuji Kusaka
    0

    I made a mistake there, if am not mistaken you are picking your source from a  website structured like this right?

    .Content

    -- Default

    --- Folder 
    ---- Sub Folder 1
    ---- Sub Folder 2
    ---- Sub Folder 3
    ---- Sub Folder 4
     

     <xsl:variable name="allNodes" select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']"/> 

    //fuji


  • Niels 63 posts 119 karma points
    Oct 04, 2011 @ 14:33
    Niels
    0

    Yes just like that, stupid me. The other elements in this xslt are just the same.

    Code blindness all the way.

    Thank you very much, karma for you!

  • Fuji Kusaka 2203 posts 4220 karma points
    Oct 04, 2011 @ 14:35
    Fuji Kusaka
    0

    Great if its working Niels.

Please Sign in or register to post replies

Write your reply to:

Draft