Copied to clipboard

Flag this post as spam?

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


  • Frederik T 242 posts 373 karma points
    Aug 18, 2011 @ 14:21
    Frederik T
    0

    Populating a slider with random nodes. With a twist.

    The site im working on, has a simple slider on the frontpage, thats supposed to list five random company profiles.

    Right now its wired up but only shows hard-coded information.

    This is the short version of the current xslt file: (short as in, ive cut it down to just one hard-coded element)

     

    <?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" xmlns:PS.XSLTsearch="urn:PS.XSLTsearch"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets PS.XSLTsearch ">


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

    <xsl:param name="currentPage"/>

    <xsl:template match="/">

    <!-- start writing XSLT -->

     <div class="g640p10" style="position:relative;">
       <h4><a href="/karriere/virksomhedsprofiler" title="Virksomhedsprofiler" class="purple">Virksomhedsprofiler</a></h4>
         
           <ul id="vpSlider">
          <li><img class="vpSliderImg" src="http://placehold.it/425x250g"
          width="425" height="250" alt="" />
          <img src="http://placehold.it/125x70g" width="125" height="70" />
          <h2>NAME HERE</h2>
          <p>Excerpt from text</p>
          <p><a hreh="#" title="Read more">Read more...</a></p>
          </li>
             
        </ul>  

           <div id="vpSliderPager"><xsl:value-of select="normalize-space('')"/></div>     
         </div>
     
      
    </xsl:template>

    </xsl:stylesheet>

    Ive searched around for getting random nodes, so i got the general gist of it, but here comes the twist.

    Each company profile, is made up of one document template, but has six sub documents, that are made as tabs, and the information is spread all over those documents.

    So, not only do i need to pick five random (of course without the possibilty of the same shown twice), which by itself is relatively easy, i have to somehow get the information from its sub nodes. (im still learning the umbraco jargon, forgive me if i confuse you).

    Main
    -Section 1
    --Sub-Section
    ---Company profiles
    ----Example company
    ------- Tab 1
    ------- Tab 2
    ------- Tab 3
    ------- Tab 4
    ------- Tab 5

    Getting information from one document type, or node so to speak, is easy enough, but the information is spread over those nodes that act as its tabs.

    Hope it helps a tiny bit.If you need any other information, please ask, and sadly, the Edit function doesnt work correctly here as im sure i want to add something after i clicked Submit.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Aug 18, 2011 @ 14:36
    Dirk De Grave
    0

    Frederik,

    I guess spitting out the info from the *Tab x* thingies (I guess those are sub nodes to the 'Example company' nodes?) depend on what type of info is contained in those nodes. Are these nodes all of the same document type? Or all different?

    If those nodes are of the same type, then you can iterate those in xslt (see code snippet below)

    <xsl:for-each select="$currentPage/* [@isDoc]">
    <xsl:value-of select="./@nodeName" />
    <xsl:value-of select="./propertyAlias" />
    </xsl:for-each>

     Above snippet iterates child nodes of the current node and writes out the node name (as it appears in the content tree) and a property who's alias is propertyAlias (change it to whatever alias you've set)

    Still confused? More questions? Just shout!

     

    Cheers,

    /Dirk

     

     

     

  • Frederik T 242 posts 373 karma points
    Aug 18, 2011 @ 22:20
    Frederik T
    0

    Thank you for your reply, im not at work right now so i cant get the names but, the document types are different. the "Example comany" is a node of a document that node alone uses, the child nodes (the tabs), are of a different document type (but they all use the same).

    If its too difficult, i will try and convince the content editors to put the info i need in the parent node, will make it easier but kind of a work-around.

Please Sign in or register to post replies

Write your reply to:

Draft