Copied to clipboard

Flag this post as spam?

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


  • Bex 444 posts 555 karma points
    Jul 19, 2010 @ 12:55
    Bex
    0

    Get SubPages from CurrentPage, but show link as the domain link

    Hello

    I seem to be missing something here.

    I have a site that is as follows:

    Main page

    --Areas
    -------Area 1
    -------------Site1
    -------------Site2
    -------Area 2
    -------------Site1
    -------------Site2

    Area is a subpage of the main site, areas sub pages of the Area page and the sites are sub folders of the areas, each site (ie site1,site2..) has it's own domain pointing at it.
    I want to list all the sites under and area on the area1/area2.. page but instead of the link being Areas/Area1/site1 I want it to point at the domain I have set for the site.

    Is there a way of getting at the domain in XSLT?

    Thanks

    Bex

     

     

     

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Jul 19, 2010 @ 13:29
    Darren Ferguson
    0

    Umbraco library defines:

    public static Domain[] GetCurrentDomains(int NodeId)

    this may be of help?

  • Bex 444 posts 555 karma points
    Jul 19, 2010 @ 14:01
    Bex
    0

    Can I use that in XSLT?

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Jul 19, 2010 @ 14:04
    Darren Ferguson
    0

    Something like:

    <xsl:for-each select="umbraco.library:GetCurrentDomains($nodeId)"> ....

     

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Jul 19, 2010 @ 22:08
    Chriztian Steinmeier
    0

    Hi Bex (+ Darren),

    The GetCurrentDomains method unfortunately can't be used in XSLT (the return type doesn't comply with anything XSLT can handle).

    I'd probably put a domain property on the Document Type for the Site nodes and use that when rendering those links.

    /Chriztian

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Jul 20, 2010 @ 09:42
    Darren Ferguson
    0

    Ah yeah, it returns an array. You could easily wrap it up to return a nodeset though I guess.

    Bex, do you have any experience writing XSL extension functions?

     

  • Bex 444 posts 555 karma points
    Jul 20, 2010 @ 09:58
    Bex
    0

    Hello!

    Darren, No I haven't writte any XSL extension functions..
    Do you have any examples of how I would acheive what I am trying to do?

    Becky

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Jul 20, 2010 @ 10:04
    Darren Ferguson
    0

    See:

    http://en.wikibooks.org/wiki/Umbraco/Create_xslt_exstension_like_umbraco.Library_in_C

    You'd need to wrap the existing umbraco library function to return a node set or similar.

     

  • Bex 444 posts 555 karma points
    Jul 20, 2010 @ 10:59
    Bex
    0

     

    To do this would I just create a function like so:

     public static string getDomain(Domains)  {
     return Domains[0]

      }

    were domains is umbraco.library:GetCurrentDomains($nodeId), or would I pass in the nodeId and then do the work off the document Id?

    Not completely sure I understand! Very new to xslt stuff and the umbraco way of doing things!

    Becky

  • Bex 444 posts 555 karma points
    Jul 20, 2010 @ 11:39
    Bex
    0

    Ok, I have almost done it, but when I try adding the namespace to the xslt file I get

    Error occured

    System.Xml.XmlException: 'urn' is an unexpected token. Expecting white space. Line 12, position 25.
    at System.Xml.XmlTextReaderImpl.Throw(Exception e)
    at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
    at System.Xml.XmlTextReaderImpl.ParseAttributes()
    at System.Xml.XmlTextReaderImpl.ParseElement()
    at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
    at System.Xml.XmlTextReaderImpl.Read()
    at System.Xml.Xsl.Xslt.XsltInput.ReadNextSiblingHelper()
    at System.Xml.Xsl.Xslt.XsltInput.ReadNextSibling()
    at System.Xml.Xsl.Xslt.XsltInput.MoveToNextSibling()
    at System.Xml.Xsl.Xslt.XsltInput.Start()
    at System.Xml.Xsl.Xslt.XsltLoader.LoadDocument()
    at System.Xml.Xsl.Xslt.XsltLoader.LoadStylesheet(XmlReader reader, Boolean include)

    my Xslt is as follows:

     

     <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>

    <?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:Domains="urn:Domains" exclude-result-prefixes="msxml umbraco.library Domains
     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="/">
    <!-- The fun starts here -->
    <ul>
    <xsl:for-each select="$currentPage/node [string(data [@alias='umbracoNaviHide']) != '1']">
     <li>
      <a href="{Domains:GetDefaultDomain(@id)}">
       <xsl:value-of select="@nodeName"/>
      </a>
     </li>
    </xsl:for-each>
    </ul>
    </xsl:template>
    </xsl:stylesheet>
    <!-- The fun starts here -->
    <ul>
    <xsl:for-each select="$currentPage/node [string(data [@alias='umbracoNaviHide']) != '1']">
     <li>
      <a href="{Domains:GetClubDefaultDomain(@id)}">
       <xsl:value-of select="@nodeName"/>
      </a>
     </li>
    </xsl:for-each>
    </ul>
    </xsl:template>
    </xsl:stylesheet>

     

     

    Can you see anything wrong?

     

    Bex

  • Bex 444 posts 555 karma points
    Jul 20, 2010 @ 11:40
    Bex
    0

    I can't edit the above message, it goes all wonky.. but my actual xslt doesn't have two of these:

     

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>

     

    at the top

  • Bex 444 posts 555 karma points
    Jul 20, 2010 @ 12:02
    Bex
    0

    Ok, such a misleading error mesage. it was because I had not put thereference in correctly in the config file.

Please Sign in or register to post replies

Write your reply to:

Draft