Copied to clipboard

Flag this post as spam?

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


  • Keith R Hubbard 175 posts 403 karma points
    May 05, 2011 @ 17:48
    Keith R Hubbard
    0

    Image Rotator not working since 4.7 upgrade

    I have upgraded the website http://www.lynchburgpawnshop.com from 4.52 to 4.7 using the proper proceedures and am having a problem with the rotators working under the new site for the services sub links.  the site is at http://2011.lynchburgpawnshop.com. ; All the rotators under each department are not functional. This works by selecting a mediaroot folder under the propertys of each department node

    <?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="MediaRootId" select="$currentPage/MediaRoot"/>
    <xsl:template match="/">

    <!-- start writing XSLT -->

    <xsl:if test="$MediaRootId != '' ">
            <!-- just added as cast-workaround -->
    <ul id="rotate">
            <xsl:for-each select="umbraco.library:GetMedia($MediaRootId, 'false')/* [@isDoc]">

                    <li>
                        <xsl:if test="@nodeTypeAlias='Image'">
                          <xsl:element name="img">
                            <xsl:attribute name="src">
                              <xsl:value-of select="umbracoFile"/>
                            </xsl:attribute>
                          </xsl:element>
                          
                          
                         
                        </xsl:if>
                  </li>

                <!-- Add other <td> entries here to display further info -->

            </xsl:for-each>
    </ul>
          </xsl:if>
    </xsl:template>

    </xsl:stylesheet>

    code for macro in template

    <div id="rotator">
    <umbraco:Macro ID="Macro1" Alias="InnerFadeImages" runat="server"></umbraco:Macro>
    </div>

    Javascriptin master template.

    <script type="text/javascript">
    $(document).ready(function() {
    $("a#gallery").fancybox();
    $("#gallery a").fancybox();
    $('ul#rotate').innerfade({
      speed: 1000,
      timeout: 8000,
      type: 'random',
      containerheight: '204px',
      containerwidth: '725px'
    });
            }
            );
    </script>


    where I select the media root folder

    This is what the new http://2011.lynchburgpawnshop.com looks like. 

     

    This is what the current http://www.lynchburgpawnshop.com looks loke

     

    Please help. 

  • Keith R Hubbard 175 posts 403 karma points
    May 05, 2011 @ 17:49
  • Keith R Hubbard 175 posts 403 karma points
    May 05, 2011 @ 17:53
    Keith R Hubbard
    0

    Is it possible to convert this one to replace the xslt above?

     

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

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

            <xsl:param name="currentPage"/>

            <msxml:script implements-prefix="random" language="C#">
                    <msxml:assembly name="umbraco"/>
                    <msxml:using namespace="umbraco"/>
                    <![CDATA[
    public int GetRandom(int minValue, int maxValue)
    {
    return umbraco.library.GetRandom().Next(minValue, maxValue);
    }
    ]]>
            </msxml:script>

            <xsl:template match="/">

                    <xsl:variable name="mediaNode" select="umbraco.library:GetMedia('1850', 'true')"/>

                    <xsl:for-each select="$mediaNode/* [@isDoc]">
                            <xsl:sort select="random:GetRandom(1, count($mediaNode/* [@isDoc]))" order="ascending" />
                            <a href="{umbraco.library:NiceUrl(data[@alias = 'Link'])}">
                                    <img src="{data [@alias='Crops']//crop/@url}" alt="pic" width="265" height="173"/>
                            </a>
                    </xsl:for-each>

            </xsl:template>

    </xsl:stylesheet>

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    May 09, 2011 @ 15:11
    Douglas Robar
    0

    Hi, Keith,

     

    I haven't studied this too closely but the following line is certainly not correct and will cause problems:

    <xsl:for-each select="umbraco.library:GetMedia($MediaRootId, 'false')/* [@isDoc]">

    ...you don't need the [@isDoc] there.

     

    But let's take this one step at a time. You're certainly close so it's just a detail here or there I think.

    1. Let's be sure the $MediaRootId is correct. To do this, add the following to the macro and let us know what is returned in the textarea in your browser when you run the macro:

    </textarea><xsl:copy-of select="$MediaRootId" /><textarea>

    It should be the ID number for the folder in the media section. Is it? Is it the right ID number?

     

    2. Assuming the answer to #1 is correct, all we need to do is get the proper XPATH in the for-each loop and the problem is solved. I don't know how familiar you are with XPATH so I'll go thorugh the steps to finding the solution...

    Add the following to see what GetMedia() is returning:

    <textarea><xsl:copy-of select="umbraco.library:GetMedia($MediaRootId, 'false')" /></textarea>

    You'll get a bunch of XML output (poorly formatted; you might want to copy it into a decent editor that will format it nicely so you can see what's there more easily). At the top is a <Folder> and below the folder should be a bunch of <Image> elements. Each Image contains the information you want, such as the umbracoFile attribute that is the path to the actual image. 

    Now that we know what GetMedia() is returning we can update the for-each's XPATH to traverse it properly:

    <xsl:for-each select="umbraco.library:GetMedia($MediaRootId, 'false')/Image">

    This says, look for every Image element returned by the GetMedia() function.

     

    After deleting the two <xsl:copy-of> statements we added for debugging your xslt will now look like this:

    <xsl:param name="currentPage"/>
    <xsl:variable name="MediaRootId" select="$currentPage/MediaRoot"/>
    <xsl:template match="/">
    <!-- start writing XSLT -->
    <xsl:if test="$MediaRootId != '' ">
            <!-- just added as cast-workaround -->
    <ul id="rotate">
            <xsl:for-each select="umbraco.library:GetMedia($MediaRootId, 'false')/Image">
                    <li>
                        <xsl:if test="@nodeTypeAlias='Image'">
                          <xsl:element name="img">
                            <xsl:attribute name="src">
                              <xsl:value-of select="umbracoFile"/>
                            </xsl:attribute>
                          </xsl:element>
                          
                          
                         
                        </xsl:if>
                  </li>
                <!-- Add other <td> entries here to display further info -->
            </xsl:for-each>
    </ul>
          </xsl:if>
    </xsl:template>

    Hope that helps.

     

    cheers,
    doug.

     

     

     

  • Keith R Hubbard 175 posts 403 karma points
    May 10, 2011 @ 17:12
    Keith R Hubbard
    0

    Thanks Doug it is resolved

Please Sign in or register to post replies

Write your reply to:

Draft