Copied to clipboard

Flag this post as spam?

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


  • Max 144 posts 166 karma points
    Jan 09, 2012 @ 07:32
    Max
    0

    list sub pages from current pages with 1 feature and random for all

    Hi i have a xslt for list sub pages from current page  i used a random fuction to generate it randomly but i also want a feature for a feature page to be on top and the rest to be generated randomly except that feature page to be on top accordinngly ..

    here is my xslt :

    <?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:msxsl="urn:schemas-microsoft-com:xslt"
      xmlns:randomTools="http://www.umbraco.org/randomTools"

      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" xmlns:tagsLib="urn:tagsLib" xmlns:BlogLibrary="urn:BlogLibrary" 
     xmlns:uForum="urn:uForum" xmlns:uForum.raw="urn:uForum.raw" xmlns:ucomponents.cms="urn:ucomponents.cms" xmlns:ucomponents.dates="urn:ucomponents.dates" xmlns:ucomponents.io="urn:ucomponents.io" xmlns:ucomponents.media="urn:ucomponents.media" xmlns:ucomponents.members="urn:ucomponents.members" xmlns:ucomponents.nodes="urn:ucomponents.nodes" xmlns:ucomponents.search="urn:ucomponents.search" xmlns:ucomponents.strings="urn:ucomponents.strings" xmlns:ucomponents.urls="urn:ucomponents.urls" xmlns:ucomponents.xml="urn:ucomponents.xml" 
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets tagsLib BlogLibrary uForum uForum.raw ucomponents.cms ucomponents.dates ucomponents.io ucomponents.media ucomponents.members ucomponents.nodes ucomponents.search ucomponents.strings ucomponents.urls ucomponents.xml msxsl randomTools">

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

    <xsl:param name="currentPage"/>
    <xsl:variable name="documentTypeAlias" select="string('SliderType')"/>
     <xsl:variable name="SlideDesc" select="slideDescription" />
        
    <xsl:template match="/">
      
      <!-- The fun starts here -->

    <xsl:for-each select="$currentPage/* [name() = $documentTypeAlias and string(umbracoNaviHide) != '1']">
      <!--<xsl:for-each select="umbraco.library:GetXmlNodeById(1296)/node">-->
      <!--<li>
        <a href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="@nodeName"/>
        </a>
      </li>-->
     <xsl:sort select="randomTools:GetRandom(0,count($currentPage/* [name() = $documentTypeAlias and string(umbracoNaviHide) != '1']))" order="ascending" />

      <div class="slide">
            <div class="sliderHeader"><xsl:value-of select="slideTitle"/></div>
            <div id="sliderImageDiv"><xsl:element name="img">
                     <xsl:attribute name="src"><xsl:value-of select="slidePhoto"/></xsl:attribute>
                     <xsl:attribute name="id">img1</xsl:attribute>
                     

      </xsl:element></div>
            
            <div class="textDiv"><xsl:value-of select="brief" disable-output-escaping="yes"/> </div>
        <xsl:choose>
    <xsl:when test="string(slideDescription) !=''">

      <div class="readmorediv" style="padding-top:2px;font-size:10px;font-style:normal;text-decoration:none;">
                  <!--<xsl:element name="a">
                     <xsl:attribute name="href">#?w=750</xsl:attribute>
                     <xsl:attribute name="rel">popup_name1<xsl:value-of select="@nodeName"/></xsl:attribute>
                      <xsl:attribute name="class">poplight</xsl:attribute>
                <xsl:value-of select="umbraco.library:GetDictionaryItem('readmore')"/>
      </xsl:element>-->
              <a href="{umbraco.library:NiceUrl(@id)}">
                  <xsl:value-of select="umbraco.library:GetDictionaryItem('readmore')"/></a>
        
        </div> 

    </xsl:when>
    <xsl:otherwise>

      
    </xsl:otherwise>
    </xsl:choose>


          
          </div>
    </xsl:for-each>
      
      </xsl:template>
        
     <msxsl:script language="c#" implements-prefix="randomTools">
        <msxsl:assembly href="../bin/umbraco.dll"/>
        <![CDATA[
            /// <summary>
            /// Gets a random integer that falls between the specified limits
            /// </summary>
            /// <param name="lowerLimit">An integer that defines the lower-boundary of the range</param>
            /// <param name="upperLimit">An integer that defines the upper-boundary of the range</param>
            /// <returns>A random integer within the specified range</returns>
            public static int GetRandom(int lowerLimit,int upperLimit) {
                Random r = umbraco.library.GetRandom();
                int returnedNumber = 0;
                lock (r)
                {
                    returnedNumber = r.Next(lowerLimit, upperLimit);
                }
                return returnedNumber;
            }
        ]]>
      </msxsl:script>




    </xsl:stylesheet>



    the feature slider page should be on top any suiggestions would be useful..

    thank you


  • Max 144 posts 166 karma points
    Jan 09, 2012 @ 08:44
    Max
    0

    any suggestions for chossing the first one to be featured the rest to be randomly generated withis list of sug pabes ..

     

  • Max 144 posts 166 karma points
    Jan 09, 2012 @ 12:09
    Max
    0

    i did it with 2 for each lops filteting the node withfeatured first then filtering the rest not featured together using 2 for each loops in xslt

     

Please Sign in or register to post replies

Write your reply to:

Draft