Copied to clipboard

Flag this post as spam?

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


  • Adam 7 posts 27 karma points
    Jul 26, 2011 @ 09:33
    Adam
    0

    List child nodes from other sites

    Hi,

    I've been banging my head against a wall for a bit on this.

    What's the best way to list child nodes from other websites in umbraco?

    Using legacy XSLT, how can I traverse down another websites node tree?

    I think I've seen this done before.

    Example

    Content

    Site 1 (@id='4901') (XSLT is running from this node)

    Site 2

    News (@id='2304') (I want to get the children of News)

    News item 1

    News item 2

    News item 3

    Any help is greatly appreciated!

    Cheers

    Adam

  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 26, 2011 @ 09:40
    Fuji Kusaka
    0

    Hi Adam,

    Am not sure of what you are asking here, are you trying to view the Child nodes of another website or Site 2 is a content folder ?

    If such you can try to create an XSLT Changeable Source.

     

     

  • John C Scott 473 posts 1183 karma points
    Jul 26, 2011 @ 10:14
    John C Scott
    0

    I guess that you mean that you have one Umbraco application which has multiple web sites in it using several root level nodes each bound to a different site?

    If that's the case you could use the Umbraco library GetXmlNodeById http://our.umbraco.org/wiki/reference/umbracolibrary/getxmlnodebyid-(1)

  • Adam 7 posts 27 karma points
    Jul 27, 2011 @ 02:43
    Adam
    0

    Hi Fuji and John,

    Thanks for your helpful suggestions, and yes I'm trying to traverse a site that is parallel to the one I'm working on, so I can source the latest news items from multiple sites for good SEO.

    I tried GetXMLNodeById http://our.umbraco.org/wiki/reference/umbracolibrary/getxmlnodebyid-(1) and it worked a treat.

    Cheers
    Adam 

    Code below

     

    <?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="SortOrder" select="$currentPage/ancestor-or-self::node/data [@alias = 'brandSortOrder']" />  
    <xsl:variable name="SortBy" select="$currentPage/ancestor-or-self::node/data [@alias = 'brandSortBy']" />
    <xsl:variable name="NumberofItemsToDisplay" select="$currentPage/ancestor-or-self::node/data [@alias = 'numberBrandArticlesFatFooter']" />
    <xsl:variable name="news-articles1" select="3949" />
    <xsl:variable name="news-articles2" select="4569" />
    <xsl:variable name="news-articles3" select="2599" />
    <xsl:variable name="news-articles4" select="2451" />
    
    <!-- We need to set data-type to number or text depending on what sortby equals -->
    <xsl:variable name="DataType">  
        <xsl:choose>  
            <xsl:when test="$SortBy='sortOrder'">  
                <xsl:value-of select="'number'" />  
            </xsl:when>  
            <xsl:otherwise>  
                <xsl:value-of select="'text'" />  
            </xsl:otherwise>  
        </xsl:choose>  
    </xsl:variable>
    
    <xsl:template match="/">
    
    <div id="fat-footer">
        <ul class="fixedwidthcentered nolist clearfix" id="brands">
            <li><a href="{$currentPage/ancestor-or-self::node/descendant-or-self::data[@alias='footerBrand1URL']}" title="{$currentPage/ancestor-or-self::node/descendant-or-self::data[@alias='footerBrand1LCaption']}"><img src="{$currentPage/ancestor-or-self::node/descendant-or-self::data[@alias='footerBrand1Logo']}" alt="{$currentPage/ancestor-or-self::node/descendant-or-self::data[@alias='footerBrand1Caption']}" /></a></li>
            <li><a href="{$currentPage/ancestor-or-self::node/descendant-or-self::data[@alias='footerBrand2URL']}" title="{$currentPage/ancestor-or-self::node/descendant-or-self::data[@alias='footerBrand2LCaption']}"><img src="{$currentPage/ancestor-or-self::node/descendant-or-self::data[@alias='footerBrand2Logo']}" alt="{$currentPage/ancestor-or-self::node/descendant-or-self::data[@alias='footerBrand2Caption']}" /></a></li>
            <li><a href="{$currentPage/ancestor-or-self::node/descendant-or-self::data[@alias='footerBrand3URL']}" title="{$currentPage/ancestor-or-self::node/descendant-or-self::data[@alias='footerBrand3LCaption']}"><img src="{$currentPage/ancestor-or-self::node/descendant-or-self::data[@alias='footerBrand3Logo']}" alt="{$currentPage/ancestor-or-self::node/descendant-or-self::data[@alias='footerBrand3Caption']}" /></a></li>
            <li><a href="{$currentPage/ancestor-or-self::node/descendant-or-self::data[@alias='footerBrand4URL']}" title="{$currentPage/ancestor-or-self::node/descendant-or-self::data[@alias='footerBrand4LCaption']}"><img src="{$currentPage/ancestor-or-self::node/descendant-or-self::data[@alias='footerBrand4Logo']}" alt="{$currentPage/ancestor-or-self::node/descendant-or-self::data[@alias='footerBrand4Caption']}" /></a></li>
        </ul>
        <ul class="fixedwidthcentered nolist" id="brands-data">
            <li class="col" id="col1">
                <ul>
                    <xsl:for-each select="umbraco.library:GetXmlNodeById($news-articles1)/node[string(data [@alias='umbracoNaviHide']) != '1']">
                        <!--order="{$SortOrder}" -->
                        <xsl:if test="position()&lt;= $NumberofItemsToDisplay">
                            <li class="ffitem">
                                <a href="{umbraco.library:NiceUrl(@id)}" title="{./data [@alias = 'PageTitle']}">
                                    <xsl:value-of select="concat(substring(umbraco.library:StripHtml(./data[@alias = 'PageTitle']),1,25),'...')" />
                                </a>
                            </li>
                        </xsl:if>
                    </xsl:for-each>
                </ul>
                </li>
            <li class="col" id="col2">
                <ul>
                    <xsl:for-each select="umbraco.library:GetXmlNodeById($news-articles2)/node[string(data [@alias='umbracoNaviHide']) != '1']">
                        <!--order="{$SortOrder}" -->
                        <xsl:if test="position()&lt;= $NumberofItemsToDisplay">
                            <li class="ffitem">
                                <a href="{umbraco.library:NiceUrl(@id)}" title="{./data [@alias = 'PageTitle']}">
                                    <xsl:value-of select="concat(substring(umbraco.library:StripHtml(./data[@alias = 'PageTitle']),1,25),'...')" />
                                </a>
                            </li>
                        </xsl:if>
                    </xsl:for-each>
                </ul>
                </li>
            <li class="col" id="col3">
                <ul>
                    <xsl:for-each select="umbraco.library:GetXmlNodeById($news-articles3)/node[string(data [@alias='umbracoNaviHide']) != '1']">
                        <!--order="{$SortOrder}" -->
                        <xsl:if test="position()&lt;= $NumberofItemsToDisplay">
                            <li class="ffitem">
                                <a href="{umbraco.library:NiceUrl(@id)}" title="{./data [@alias = 'PageTitle']}">
                                    <xsl:value-of select="concat(substring(umbraco.library:StripHtml(./data[@alias = 'PageTitle']),1,25),'...')" />
                                </a>
                            </li>
                        </xsl:if>
                    </xsl:for-each>
                </ul>
                </li>
            <li class="col nomarr" id="col4">
                <ul>
                    <xsl:for-each select="umbraco.library:GetXmlNodeById($news-articles4)/node[string(data [@alias='umbracoNaviHide']) != '1']">
                        <!--order="{$SortOrder}" -->
                        <xsl:if test="position()&lt;= $NumberofItemsToDisplay">
                            <li class="ffitem">
                                <a href="{umbraco.library:NiceUrl(@id)}" title="{./data [@alias = 'PageTitle']}">
                                    <xsl:value-of select="concat(substring(umbraco.library:StripHtml(./data[@alias = 'PageTitle']),1,25),'...')" />
                                </a>
                            </li>
                        </xsl:if>
                    </xsl:for-each>
                </ul>
                </li>
        </ul>
    </div>
    
    </xsl:template>
    
    </xsl:stylesheet>
  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 27, 2011 @ 04:30
    Fuji Kusaka
    0

    Hi Adam,

    Nice work if you got it working.

Please Sign in or register to post replies

Write your reply to:

Draft