Copied to clipboard

Flag this post as spam?

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


  • Max Mumford 266 posts 293 karma points
    Sep 02, 2010 @ 11:39
    Max Mumford
    0

    XSLT nav generation bug after umbraco upgrade

    Hi all,

    After following the recommended upgrade guide (http://www.karlkopp.com/blog/2010/7/27/upgrading-umbraco-40x-to-45xand upgrading from 4.0.4.2 to 4.5.2 (all updates going smoothly and the config wizard showing no errors), the menu tree is now longer being generated and the layout and design are messed up. See screen shots below:

    4.0.4.2

    4.5.2

    Nothing else in the site has changed - all site files, databases and XSLT files have remained the same, yet the site is now only generating a link for the home page and ignoring all other pages as should be seen in the screen shot for 4.0.4.2.

     

    Here is a link to the HTML source code for:

    4.5.2: http://www.fileden.com/files/2010/9/2/2958919/ava%20broken.txt *4.5.2*

    4.0.4.2: http://www.fileden.com/files/2010/9/2/2958919/ava%20working.txt *4.0.4.2*

     

    Here are links to the XSLT files that generate the menu:

    AvaBanner.xslt:

    http://www.fileden.com/files/2010/9/2/2958919/avaBanner.xslt%20BROKEN.txt *4.5.2*

    http://www.fileden.com/files/2010/9/2/2958919/avaBanner.xslt%20WORKING.txt *4.0.4.2*

    AvaNav.xslt

    http://www.fileden.com/files/2010/9/2/2958919/avaNav.xslt%20%20BROKEN.txt *4.5.2*

    http://www.fileden.com/files/2010/9/2/2958919/avaNav.xslt%20%20WORKING.txt *4.0.4.2*

    AvaNavigationMenu.xslt

    http://www.fileden.com/files/2010/9/2/2958919/avaNavigationMenu.xslt%20BROKEN.txt *4.5.2*

    http://www.fileden.com/files/2010/9/2/2958919/avaNavigationMenu.xslt%20WORKING.txt *4.0.4.2*

    Can anybody shed any light on this?

    Thanks,

    Max.

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Sep 02, 2010 @ 12:15
    Ismail Mayat
    0

    Looks like your schema is now 4.5 which is new schema but your xslts are still old schema. You have 2 options either keep old schema and update web.config to use old schema or upgrade your existing xslts using the excellent http://our.umbraco.org/projects/developer-tools/xsltupdater-for-umbraco i used it just today to upgrade cog navigation xslt 

     

    Regards

    Ismail

  • Max Mumford 266 posts 293 karma points
    Sep 02, 2010 @ 12:38
    Max Mumford
    0

    Hi,

    Thanks very much for your reply! I installed and ran the xslt updater and sure enough, it fixed the layout of the page but the menu is still only showing a link for the home page, see screen shot:

    Here are some changes that the xslt-updater advised me to change manually:

     

    Warning: these lines have not been replaced automatically, but they might need to be edited

    <xsl:with-param name="item" select="$item/data[contains($searchFields, concat(',',@alias,','))]"/>

    <xsl:variable name="weighting" select="ps:power(2, number(ps:hitCount(substring-after($searchFields,string($item/@alias)), ','))-1)"/>

    <xsl:when test="contains($searchFields, concat(',',$item/@alias,','))">

    <xsl:variable name="remaining" select="$item/following-sibling::data[contains($searchFields, concat(',',@alias,','))]"/>

    $yetPossibleNodes[data[(contains($searchFields, concat(',',@alias,','))

     

    It seems likely that these are responsible for the current menu error. Can you please advise me how these changes can be made?

    Thanks again!

    Max.

  • Max Mumford 266 posts 293 karma points
    Sep 02, 2010 @ 13:05
    Max Mumford
    0

    Also does the schema change in 4.5 make any changes to the database that I should know about?

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Sep 02, 2010 @ 13:41
    Chriztian Steinmeier
    1

    Hi Max,

    I did a quick run-through of the offending lines above - they should read something like this in the new format:

    <xsl:with-param name="item" select="$item/*[contains($searchFields, concat(',', name(), ','))]" />
    
    <xsl:variable name="weighting" select="ps:power(2, number(ps:hitCount(substring-after($searchFields, name($item)), ',')) - 1)" />
    
    <xsl:when test="contains($searchFields, concat(',', name($item), ','))">
    
    <xsl:variable name="remaining" select="$item/following-sibling::*[contains($searchFields, concat(',', name(), ','))]" />
    
    $yetPossibleNodes[*[contains($searchFields, concat(',' , name(), ','))

    (The last one is incomplete in the one you pasted so might need a little tweaking...)

    /Chriztian

  • Warren Buckley 2106 posts 4836 karma points MVP 7x admin c-trib
    Sep 02, 2010 @ 13:41
    Warren Buckley
    0

    OK I'll try and convert the above lines for you, maybe a bit tricky without knowing what the XSLT is doing exactly but here goes.

    <xsl:with-param name="item" select="$item/* [contains($searchFields, concat(',',@alias,','))]"/>
    <xsl:variable name="remaining" select="$item/following-sibling::* [contains($searchFields, concat(',',@alias,','))]"/>

     

    The other lines look specific to some XSLT Extension library and refer to other XML structure it seems.
    Anywhere data or node is used it needs to be updated in the xPath, either with the specific doctype alias or the alias of a property of a doctype or alternatively * to look for all XML nodes.

    Hopefully this will help you and get your site back in shape.

    But if upgrading to 4.5.X schema is causing you problems I recommend you stick to the legacy schema config option.

    Warren :)

  • Warren Buckley 2106 posts 4836 karma points MVP 7x admin c-trib
    Sep 02, 2010 @ 13:44
    Warren Buckley
    0

    Reading Chriztian's post it seems he has a better grasp of what you were after, so I recommend his solution over mine.

    Warren :)

  • Max Mumford 266 posts 293 karma points
    Sep 02, 2010 @ 14:02
    Max Mumford
    0

    Thanks Chriztian and Warren for both of your very useful input :)

    Iv made the changes suggested by Chriztian but the same error in the latest sreenshot still persists.

    Chriztian mentioned that the last line given in the error wasnt complete so here is the complete block:

     

    $yetPossibleNodes[attribute::*[(contains($searchFields,name())
                                                  and contains(ps:uppercase(umbraco.library:StripHtml(string(.))), $searchTerm)) ]]
                                                  |
                                                  $yetPossibleNodes[*[contains($searchFields, concat(',' , name(), ','))
                                                  and contains(ps:uppercase(umbraco.library:StripHtml(string(.))), $searchTerm)) ]]

     

    Other than that the xslt seems to have been all properly converted... any other reasons why the nav might not be generating? do you need any more code from me?

    - im very new to umbraco, xslt, xml, aspx........ :)

  • Max Mumford 266 posts 293 karma points
    Sep 02, 2010 @ 15:47
    Max Mumford
    0

    Iv just found another xslt file that looks like it's key in generating the menu. can you check the contents to make sure it should work with the new schema?:

     

    <?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"/>

    <xsl:template match="/">

    <!-- start writing XSLT -->

    <ul id="Navi">
    <xsl:for-each select="$currentPage/ancestor::root/node [string(./umbracoNaviHide) != '1']">
      <li>
        <xsl:if test="$currentPage/@id=current()/@id">
          <xsl:attribute name="class">Selected</xsl:attribute>
        </xsl:if>
        <a href="{umbraco.library:NiceUrl(@id)}">
          <xsl:attribute name="title"><xsl:value-of select="@nodeName" /></xsl:attribute>
          <xsl:value-of select="@nodeName" />
        </a>
      </li>
    </xsl:for-each>

    <xsl:for-each select="$currentPage/ancestor-or-self::*[@isDoc] [@level=1]/node [string(./umbracoNaviHide) != '1']">
      <li>
        <xsl:if test="$currentPage/ancestor-or-self::*[@isDoc]/@id = current()/@id">
          <xsl:attribute name="class">Selected</xsl:attribute>
        </xsl:if>
        <a href="{umbraco.library:NiceUrl(@id)}">
          <xsl:attribute name="title"><xsl:value-of select="@nodeName" /></xsl:attribute>
          <xsl:value-of select="@nodeName" />
        </a>
      </li>
    </xsl:for-each>
    </ul>


    </xsl:template>

    </xsl:stylesheet>

  • Max Mumford 266 posts 293 karma points
    Jul 11, 2011 @ 18:47
    Max Mumford
    0

    For anybody elses reference, here is an update:

    We decided to go for a pre xslt schema change release as 4.5.2 was breaking some other things of the website. We recently however upgraded to 4.7 and so I had to convert all the XSLT. I had since taken the level 1 developer course so I was much better prepard :P Here is the output of our slightly modified navigation menu compatible with the new xslt schema so for anybody else with similar problems to the script above this post, refer to the below script for corresponding changes:

    <?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"/>

     

    <xsl:variable name="level" select="1"/>

     

    <xsl:template match="/">

     

      <div class="navtree">

        <table cellspacing="0">

          <tr>

            <td id="navleft"></td>

            <td id="navcentre">

              <ul>

                <li>

                  <!-- output home page node then run through template for all other top level nodes -->

                  <xsl:if test="$currentPage/@nodeName = 'Home'">

                    <xsl:attribute name="class">current</xsl:attribute>

                  </xsl:if>

                  <a href="/">Home</a></li></ul>

                  <xsl:call-template name="printListe">

                    <xsl:with-param name="node" select="$currentPage/ancestor-or-self::* [@isDoc and @level = 1]"/>  

                    <xsl:with-param name="id" select="string('treemenu1')"/>  

                  </xsl:call-template>

            </td>

            <td id="navright"></td>

          </tr>

        </table>

      </div>

      

    </xsl:template>

     

    <xsl:template name="printListe">

      <xsl:param name="node"/>

      <xsl:param name="id"/>

     

      <xsl:if test="$node/umbracoNaviHide != '1'">

        <xsl:if test="count($node/* [@isDoc and umbracoNaviHide != 1]) &gt; 0">

          <ul>

            <xsl:if test="$id != ''">

              <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>

            </xsl:if>

            <xsl:for-each select="$node/* [@isDoc and umbracoNaviHide != 1]">

              <!-- run a bunch of if's for specific nodes, e.g. hide blog day folders and shrink long node names -->

              <xsl:choose>

                <!-- hide old blog day folders -->

                <xsl:when test="@level = 5 and name() = 'umbracoBlogDateFolder' or name() = 'uBlogsyPost'">

                  <xsl:call-template name="buildLi">

                    <xsl:with-param name="node" select="." />

                    <xsl:with-param name="href" select="." />

                    <xsl:with-param name="text" select="." />

                    <xsl:with-param name="stop" select="1" />

                  </xsl:call-template>

                </xsl:when>

                <!-- hide DateFolder package DateFolder month folder node -->

                <xsl:when test="@level = 5 and name() = 'DateFolder'">

                  <xsl:call-template name="buildLi">

                    <xsl:with-param name="node" select="." />

                    <xsl:with-param name="href" select="umbraco.library:NiceUrl(@id)" />

                    <xsl:with-param name="text" select="umbraco.library:FormatDateTime(@createDate, 'MMMM')" />

                    <xsl:with-param name="stop" select="1" />

                  </xsl:call-template>

                </xsl:when>

                <!-- format nice month names for blog month folders -->

                <xsl:when test="@level = 4 and name() = 'umbracoBlogDateFolder' or name() = 'DateFolder'">

                  <xsl:call-template name="buildLi">

                    <xsl:with-param name="node" select="." />

                    <xsl:with-param name="href" select="umbraco.library:NiceUrl(@id)" />

                    <xsl:with-param name="text" select="umbraco.library:FormatDateTime(@createDate, 'MMMM')" />

                    <xsl:with-param name="stop" select="0" />

                  </xsl:call-template>

                </xsl:when>

                <!-- output links that dont need modification -->

                <xsl:otherwise>

                  <xsl:call-template name="buildLi">

                    <xsl:with-param name="node" select="." />

                    <xsl:with-param name="href" select="umbraco.library:NiceUrl(@id)" />

                    <xsl:with-param name="text" select="@nodeName" />

                    <xsl:with-param name="stop" select="0" />

                  </xsl:call-template>

                </xsl:otherwise>

              </xsl:choose>

            </xsl:for-each>

          </ul>

        </xsl:if>

      </xsl:if>

    </xsl:template>

     

        

    <!-- nav list item builder template, used above -->

    <xsl:template name="buildLi">

      <xsl:param name="node" />

      <xsl:param name="href" />

      <xsl:param name="text" />

      <xsl:param name="stop" />

      

      <xsl:choose>

        <xsl:when test="$stop!= 1">

          <li>

            <a>

              <xsl:attribute name="href">

                <xsl:value-of select="$href" />

              </xsl:attribute>

              <xsl:if test="string-length($text) &gt; 25">

                <xsl:attribute name="title">

                  <xsl:value-of select="$text" />

                </xsl:attribute>

              </xsl:if>

              

              <!-- if text needs shrinking, add full length version in title -->

              <xsl:choose>

                <xsl:when test="string-length(@nodeName) &gt; 25">

                  <xsl:value-of select="concat((substring($text,0,24)),'...')" />

                </xsl:when>

                <xsl:otherwise>

                  <xsl:value-of select="$text" />

                </xsl:otherwise>

              </xsl:choose> 

            </a>

            

            <!-- shrink text if need be -->

            <xsl:if test="count($node/*[@isDoc and umbracoNaviHide != 1]) &gt; 0">

              <xsl:call-template name="printListe">

                <xsl:with-param name="node" select="."/>

              </xsl:call-template>

            </xsl:if>

          </li>

        </xsl:when>

        <xsl:otherwise>

          <li><a style="display: none"></a></li>

          <!-- run template through child elements -->

          <xsl:call-template name="printListe">

            <xsl:with-param name="node" select="."/>

          </xsl:call-template>

        </xsl:otherwise>

      </xsl:choose>

    </xsl:template>

       

    </xsl:stylesheet>

  • Max Mumford 266 posts 293 karma points
    Jul 11, 2011 @ 18:47
    Max Mumford
    0

    *blank post*

Please Sign in or register to post replies

Write your reply to:

Draft