Copied to clipboard

Flag this post as spam?

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


  • Eddie Foreman 215 posts 288 karma points
    Dec 13, 2010 @ 14:56
    Eddie Foreman
    0

    Show in Footer

    Hi All,

    Just starting to move things over to the new schema.  I had an old xslt which showed allowed the user to show/hide a page in the footer menu.

    The old xslt is:

    <?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:template match="/">
    <ul id="footer-menu">
    <li>
    <xsl:if test="string($currentPage/@level) = '1'">
    <xsl:attribute name="class">active</xsl:attribute>
    </xsl:if>
    <a href="/">
    <xsl:text>Home</xsl:text>
    </a>
    </li>
    <xsl:for-each select="$currentPage/ancestor-or-self::node/descendant-or-self::node/node [string(data[@alias='showInFooter']) = '1']">
    <li>
    <a href="{umbraco.library:NiceUrl(@id)}">
    <xsl:value-of select="@nodeName" />
    </a>
    </li>
    </xsl:for-each>
    </ul>
    </xsl:template>


    </xsl:stylesheet>

    Have changed the following line, but the when the property is checked the page does not show.

    <xsl:for-each select="$currentPage/ancestor-or-self::node/descendant-or-self::node/* [@isDoc][string(showInFooter) = '1']">

     

    I'm sure it's somthing simple, just need to get use to the new syntax.

    Thanks

    Eddie

     

  • Dan 1288 posts 3921 karma points c-trib
    Dec 13, 2010 @ 14:59
    Dan
    0

    Hi Eddie,

    Try:

    <xsl:for-each select="$currentPage/ancestor-or-self::node/descendant-or-self::node/* [@isDoc and string(showInFooter) = '1']">
  • Thijs Kuipers 43 posts 66 karma points
    Dec 13, 2010 @ 15:43
    Thijs Kuipers
    1

    A node is no longer called "node", it's called whatever the document type alias is. So it would become something like:

    <xsl:for-each select="$currentPage/ancestor-or-self::*[@isDoc]/descendant-or-self::*[@isDoc]/*[@isDoc and string(showInFooter) = '1']">


    The XPath you're using is a bit confusing though. I would suggest trying something like:

    <xsl:for-each select="$currentPage/ancestor-or-self::*[@level = 1]//*[@isDoc and string(showInFooter) = '1']">

    Edit: updated "string(data[@alias = '<nodeTypeAlias>'])" to "string(<nodeTypeAlias>)".

  • Dan 1288 posts 3921 karma points c-trib
    Dec 13, 2010 @ 15:56
    Dan
    1

    Actually Eddie, ignore me!  I did that quickly and didn't look at your XPath - I think you'll find Thijs is much closer to the mark.  The new schema does indeed use the doctype alias instead of 'node'.  The code in the square brackets does stand though - it's what you need to 'filter' your selection (isDoc ensures that just content nodes are returned, and the other part ensures just the nodes marked to show in footer are returned).

  • Eddie Foreman 215 posts 288 karma points
    Dec 13, 2010 @ 16:24
    Eddie Foreman
    0

    Hi Dan and Thijs,

    Thanks for your quick replies,

    Sorry forgot to mention that the showInFooter true/false element is set in a master document type (alias of  'master').  Do I need to add the alias to the xpath?

    Thanks,

    Eddie

  • Eddie Foreman 215 posts 288 karma points
    Dec 13, 2010 @ 16:37
    Eddie Foreman
    0

    Hi Guys,

    Ignore last post, Thijs you solution worked a treat thanks.

    Eddie

  • stephen 32 posts 52 karma points
    Jan 10, 2011 @ 14:26
    stephen
    0

    Hey guys,

    I'm trying to create a footer for my site but I'm having difficulty. I'm new to umbraco so hopefully one of you can help me.

    So far I have my XSLT and the show in footer property but when I check it, nothing seems to happen for me. I have used some of the XSLT from above and this is what it looks like:

    <?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:template match="/">
      <xsl:for-each select="$currentPage/ancestor-or-self::*[@level = 1]//*[@isDoc and string(showInFooter) = '1']">  
                           
          <a href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="@nodeName" />
          </a>
      </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>

    I have then added the following to my master page, in the position I want my footer to appear:

    <umbraco:Macro Alias="FooterNav" runat="server"></umbraco:Macro> 

    When I go to all my page properties and select show In Footer nothing seems to happen.

    I'm probably doing something very silly, anybody got any ideas?

  • Thijs Kuipers 43 posts 66 karma points
    Jan 10, 2011 @ 15:03
    Thijs Kuipers
    0

    Hi Stephen, first a couple of checks:

    • Are you using Umbraco 4.5 or up?
    • Have you upgraded from an existing 4.0 or lower Umbraco installation?
    • Are you using the legacy (pre 4.5) or new (since 4.5) XML schema?

    When you don't know, but you didn't upgrade and you are using version 4.5+, it's probably the new schema.

    If that's the case, I don't know why it isn't working, since the XPath seems correct, provided:

    • There is a property on the document type you want to appear in the footer, named "showInFooter" of type "True/False".

    You could try and see what is actually returned from your XPath using

    <xsl:copy-of select="<XPATH"/>

    This instead of (or preceding) the rest of the contents of your current <template match="/" />

  • stephen 32 posts 52 karma points
    Jan 10, 2011 @ 15:32
    stephen
    0

    Hi Thijs,

    Thank you for your reply,

    I have just recently installed umbraco around 3-4weeks ago. I just checked the web config file and it says:

     <add key="umbracoConfigurationStatus" value="4.5.2" />

    I assume this is the version of umbraco I'm running.
    I was however having an issue a while ago with a .NET user control and I had to compile with 3.5 rather than 4.

     Here's my old thread and the solution I tried if you would like to see what I did:

    http://our.umbraco.org/forum/getting-started/questions-about-runway-and-modules/15896-Net-User-Control?p=0

    Could this be why I am having issues now?

    Also when messing around with the XSLT I can see some items in the footer when I put "!= 1"

    <xsl:for-each select="$currentPage/ancestor-or-self::*[@level = 1]//*[@isDoc and string(showInFooter) != '1']">  

     I can see the my footer regardless of having show in footer selected or not.

    Sorry for such a silly question but where do i place <xsl:copy-of select="<XPATH"/> in order to see what is returned?

  • Thijs Kuipers 43 posts 66 karma points
    Jan 10, 2011 @ 15:42
    Thijs Kuipers
    0

    Hi Stephen, I'm not sure you answered the part "is there a 'showInFooter' property of type 'True/False' on the document type you want to appear in the footer"?

    You can check your assumptions by opening (on the server) the file in App_Data\umbraco.config , it's the XML cache file. This would allow you to browse the nodes and their attributes/properties.

    And I meant something like this (partial XSLT):

     

    <xsl:param name="currentPage"/>
    <xsl:template match="/"> <xsl:copy-of select="$currentPage/ancestor-or-self::*[@level = 1]//*[@isDoc and string(showInFooter) = '1']"> </xsl:template>

     

  • stephen 32 posts 52 karma points
    Jan 10, 2011 @ 16:20
    stephen
    0

    Hi Thijs,

    I followed your instructions and some nodes in the umbraco config file have:

    <ShowInFooter>1</ShowInFooter>

    While others have

    <ShowInFooter>0</ShowInFooter>

    I then followed the suggested XSLT code but it did not return anything

  • Thijs Kuipers 43 posts 66 karma points
    Jan 10, 2011 @ 16:33
    Thijs Kuipers
    0

    Hi Stephen,

    Unless I'm totally wrong, I think you need to take case-sensitivity (?spelling) into account. "showInFooter" is not the same as "ShowInFooter".

  • stephen 32 posts 52 karma points
    Jan 10, 2011 @ 17:06
    stephen
    0

    Hi Thijs,

    Just want to say thank you so much for the help! you were right about the case sensitive cannot believe I did something that stupid!

    Once again thanks!

  • Thijs Kuipers 43 posts 66 karma points
    Jan 10, 2011 @ 17:20
    Thijs Kuipers
    0

    It's not stupid, you just had to experience it the hard way. Now you will never forget! Glad I could be of help.

Please Sign in or register to post replies

Write your reply to:

Draft