Copied to clipboard

Flag this post as spam?

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


  • sritchie 48 posts 80 karma points
    Nov 01, 2009 @ 13:43
    sritchie
    0

    Generate RSS feed from a given node in a multi domain site

    Hi Guys,

    I've done a pretty thorough search on the forum & can't find anything on this - so forgive me if this is already out there.

    I have a multi site installation with 5 domains/sites and need to generate an rss feed from a given node within each site.

    So effctively I'll have RSS feeds from 5 domains. I've had issues with getting this working when more than 1 domain is asociated with the Umbraco installation. Has anybody done anything similar?

    To break it down, It is a website for a small group of recruitment companies & all of which require an RSS feed for advertised jobs.

    I'd appreciate any assistance.

     

    Thanks

     

  • Rasmus Berntsen 215 posts 253 karma points c-trib
    Nov 02, 2009 @ 12:18
    Rasmus Berntsen
    0

    What's the specific problem? I have RSS Feeds on several multi-language sites... :)

  • sritchie 48 posts 80 karma points
    Nov 02, 2009 @ 17:06
    sritchie
    0

    Hmmm...

    ok - for starters I wasn't generating the RSS using the XSLT for each node.

    XSLT is something I'm not too familiar with, so I'd appreciate if anyone can point me at any directions on how to setup the XSLT snippet in V4 to actively generate an RSS feed from content produced under a specific node. I can't seem to find any directions anywhere on this subject.

    This method should work perfectly under a multi domain site, I'm assuming?

    Thanks Guys.

  • Kim Andersen 1447 posts 2197 karma points MVP
    Nov 02, 2009 @ 17:52
    Kim Andersen
    0

    What do you want to create the feed over? From the given node, and all of the underlying nodes? Or the whole site where the node is in?

     

    I have a script that takes the current node, and creates a RSS-feed from all of the underlying nodes. This means that if you stand on the frontpage, you will get a feed over the whole page. If you stand on a level 4-node, you'll get a feed over level 5,6,7 etc., under that node. So actually it's possible to get a different feed on every page of your site, wich makes it pretty flexible. But is this what you are searching for?

  • sritchie 48 posts 80 karma points
    Nov 03, 2009 @ 07:48
    sritchie
    0

    Hi Kim,

    Sounds like it may be, yes.

    I have 4 Home page nodes for 4 separate domains & under that I have an employment node. I'm wanting to generate the RSS from this employment node on each of the 4 domains. i.e. www.domain1.com/domain1rss.xml, www.domain2.com/domain2rss.xml, www.domain3.com/domain3rss.xml, www.domain4.com/domain4rss.xml.

    would that work effectively for this scenario?

    Thanks

  • sritchie 48 posts 80 karma points
    Nov 03, 2009 @ 07:50
    sritchie
    0

    I should have said I'm wanting to generate the RSS from everything UNDER this employment node

  • sritchie 48 posts 80 karma points
    Nov 05, 2009 @ 09:29
    sritchie
    0

    Please? Any assistance with this one? I'd be truly appreciative :)

  • atze187 160 posts 215 karma points
    Nov 05, 2009 @ 11:26
    atze187
    0

    Umbraco has everything to accomplish your mission, basically you want to use a macro based on the "List Sub Pages From A Changable Source" template and change it to fit the rss specification, create an empty page with template, put your macro in there and reference the feed in your employment page.

    Since my timetable is very tight today, i have no time to wrap it in a package right now, but if you're not that desperate, i'll try tonight.

    Cheers,
    André

  • Kim Andersen 1447 posts 2197 karma points MVP
    Nov 05, 2009 @ 21:37
    Kim Andersen
    0

    Ahh sorry sritchie, I totaly forgot about this post.

    We did something like this earlier:

    1. Create a XSLT macro, and in the XSLT-file copy the belov code in:

    <?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:variable name="alleNyheder" select="$currentPage//node" />
        <!-- SORTING BY DATE -->
        <xsl:variable name="sort">
            <news>
                <xsl:for-each select="$alleNyheder[@template='1092'][data[@alias='hideInFeed'] != '1']">
                    <news>
                        <id>
                            <xsl:value-of select="./@id"></xsl:value-of>
                        </id>
                        <date>
                             <xsl:value-of select="./@updateDate"/>
                        </date>
                    </news>

                </xsl:for-each>
            </news>
        </xsl:variable>
        <!-- SORTING BY DATE END -->

    <!-- start writing XSLT -->
    <xsl:value-of select="umbraco.library:ChangeContentType('text/xml')"/>
        <rss version="2.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/" xmlns:atom="http://www.w3.org/2005/Atom">
            <channel>
                <title>
                    <xsl:value-of select="$currentPage/data[@alias='title']"/>
                </title>
                <link>http://<xsl:value-of select="umbraco.library:RequestServerVariables('SERVER_NAME')" /><xsl:value-of select="umbraco.library:NiceUrl($currentPage/@id)"/>
                </link>
                <description>
                    RSS-feed for all of the pages under "<xsl:value-of select="$currentPage/data[@alias='title']"/>"
                </description>


                <xsl:for-each select="msxml:node-set($sort)/news/news">
                    <xsl:sort data-type="text" select="date" order="descending" />
                    <xsl:variable name="node" select="umbraco.library:GetXmlNodeById(id)"/>

                    <item>
                        <title>
                            <xsl:value-of select="$node/data[@alias='title']"/>
                        </title>
                        <link>http://<xsl:value-of select="umbraco.library:RequestServerVariables('SERVER_NAME')" /><xsl:value-of select="umbraco.library:NiceUrl($node/@id)"/></link>
                        <description>
                            <xsl:choose>
                                <xsl:when test="$node/data[@alias='manchet'] != ''">
                                    <xsl:value-of select="$node/data[@alias='manchet']"/>
                                </xsl:when>
                                <xsl:otherwise></xsl:otherwise>
                            </xsl:choose>
                        </description>
                        <pubDate> 
                             <xsl:value-of select="umbraco.library:FormatDateTime($node/@updateDate, 'ddd, dd MMM yyyy hh:mm:ss')"/> +0000
                        </pubDate>
                    </item>
                </xsl:for-each>          
            </channel>

        </rss>

    </xsl:template>
    </xsl:stylesheet>

    This code includes every page that has a tempalte, with an ID of 1092. If you just want every pages in your site, remove the

    [@template='1092']

    In the first for-each.

    2. Create a new template, and call it something like 'rssfeed'.

    In the 'rssfeed'-tempalte copy the belov code:

    <%@ Master Language="C#" MasterPageFile="/umbraco/masterpages/default.master" AutoEventWireup="true" %>

    <asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
         <umbraco:Macro Alias="rssFeed" runat="server"></umbraco:Macro>
    </asp:Content>

    Remember to include the right macro. In my case my macro was called 'rssFeed', as you can see.

     

    Now you should be able to see your rss-feed if you type in an alttemplate in the url. Like this: www.domain1.com?alttemplate=rssfeed

    Hope this works for you, otherwise say so...

  • sritchie 48 posts 80 karma points
    Nov 06, 2009 @ 07:14
    sritchie
    0

    Thanks Guys :)

    Much appreciated - I'll give this a go & let you know how I go.

    Simon.

  • sritchie 48 posts 80 karma points
    Nov 06, 2009 @ 08:38
    sritchie
    0

    OK,

    There is an RSS being generated from the alttemplate - but it is currently still empty.

    I have nominated the template id of the template utilised for the RSS,

    I know I'm missing something small but can't seem to see what else I need to customise.

    Thanks Kim

    Simon

  • Kim Andersen 1447 posts 2197 karma points MVP
    Nov 06, 2009 @ 22:29
    Kim Andersen
    0

    Maybe you could try removing this:

    [data[@alias='hideInFeed'] != '1']

    from the first <xsl:for-each>.

     

    I used this piece of code to put a true/false property on every page. When the checkbox was checked, then the page wouldn't be included in the RSS-feed.

     

    Does it work, if you remove that piece of code Simon?

  • Kim Andersen 1447 posts 2197 karma points MVP
    Nov 13, 2009 @ 10:09
    Kim Andersen
    0

    Did it work Simon?

  • sritchie 48 posts 80 karma points
    Nov 19, 2009 @ 10:24
    sritchie
    0

    Sorry Kim,

    I had been side swiped with some other work.

    I was able to get an RSS feed but it was still empty - I'll focus on it again this week

    Thanks for the help

    Simon

  • sritchie 48 posts 80 karma points
    Nov 21, 2009 @ 10:23
    sritchie
    0

    Hi there Kim,

    A Little odd, but as before I do have an RSS but it is empty,

    see my code below - as modified from the code you put up:

     

    <?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:variable name="alleNyheder" select="$currentPage//node" />
        <!-- SORTING BY DATE -->
        <xsl:variable name="sort">
            <news>
                <xsl:for-each select="$alleNyheder[@template='1271']">
                    <news>
                        <id>
                            <xsl:value-of select="./@id"></xsl:value-of>
                        </id>
                        <date>
                             <xsl:value-of select="./@updateDate"/>
                        </date>
                    </news>

                </xsl:for-each>
            </news>
        </xsl:variable>
        <!-- SORTING BY DATE END -->

    <!-- start writing XSLT -->
    <xsl:value-of select="umbraco.library:ChangeContentType('text/xml')"/>
        <rss version="2.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/" xmlns:atom="http://www.w3.org/2005/Atom">
            <channel>
                <title>
            Trades and Labour Hire
                </title>
                <link>http://<xsl:value-of select="umbraco.library:RequestServerVariables('SERVER_NAME')" /><xsl:value-of select="umbraco.library:NiceUrl($currentPage/@id)"/>
                </link>
                <description>
                    RSS feed for Trades and Labour Hire job positions
                </description>


                <xsl:for-each select="msxml:node-set($sort)/news/news">
                    <xsl:sort data-type="text" select="date" order="descending" />
                    <xsl:variable name="node" select="umbraco.library:GetXmlNodeById(id)"/>

                    <item>
                        <title>
                            <xsl:value-of select="$node/data[@alias='JobTitle']"/>, <xsl:value-of select="$node/data[@alias='JobLocation ']"/>
                        </title>
                        <link>http://<xsl:value-of select="umbraco.library:RequestServerVariables('SERVER_NAME')" /><xsl:value-of select="umbraco.library:NiceUrl($node/@id)"/></link>
                        <description>
                            <xsl:choose>
                                <xsl:when test="$node/data[@alias='JobDescription'] != ''">
                                    <xsl:value-of select="$node/data[@alias='JobDescription']"/>
                                </xsl:when>
                                <xsl:otherwise></xsl:otherwise>
                            </xsl:choose>
                        </description>
                        <pubDate> 
                             <xsl:value-of select="umbraco.library:FormatDateTime($node/@updateDate, 'ddd, dd MMM yyyy hh:mm:ss')"/> +0000
                        </pubDate>
                    </item>
                </xsl:for-each>          
            </channel>

        </rss>

    </xsl:template>
    </xsl:stylesheet>

     

    Not sure whats happening here - any ideas?

  • Kim Andersen 1447 posts 2197 karma points MVP
    Nov 21, 2009 @ 12:41
    Kim Andersen
    0

    And you do have some nodes that uses a tempate with an id of 1271 right?

  • sritchie 48 posts 80 karma points
    Nov 21, 2009 @ 15:56
    sritchie
    0

    Yep - definately got 3 which should be appearing from what I can see

  • Kim Andersen 1447 posts 2197 karma points MVP
    Nov 21, 2009 @ 20:07
    Kim Andersen
    0

    Hmm....What does the source-code of the outputted RSS contain. I mean could you post the source from the rss-feed?

  • sritchie 48 posts 80 karma points
    Nov 22, 2009 @ 03:56
    sritchie
    0

    Sure

    Its completely empty as you can see

    <rss version="2.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/" xmlns:atom="http://www.w3.org/2005/Atom"><channel>
    <title>
    Trades and Labour Hire
    </title>
    <link>http://xxxxx.xxxx.net.au?alttemplate=RSSFEEDTLH
    </link>
    <description>
    RSS feed for Trades and Labour Hire job positions
    </description>
    </channel></rss>
  • Kim Andersen 1447 posts 2197 karma points MVP
    Nov 22, 2009 @ 16:08
    Kim Andersen
    1

    It looks like $sort is empty. Could you write out the variable, and sees what it contains?

    And just to be sure. You do type in the url to the feed like this right: www.yourdomain.com?alttempalte=rssfeed or www.yourdomain.com/rssfeed.aspx (if your template is called rssfeed)

     

  • sritchie 48 posts 80 karma points
    Nov 23, 2009 @ 08:13
    sritchie
    0

    Ok, I do feel a bit like a tool now - I was only typing the top level domain, instead of down to the sub level that I wanted.

    All working now. Briliant.

    Thanks Kim, you were a great help.

    Simon

  • Kim Andersen 1447 posts 2197 karma points MVP
    Nov 23, 2009 @ 09:48
    Kim Andersen
    0

    Great Simon :)

    Glad I could help. Remember to mark this post as answered.

Please Sign in or register to post replies

Write your reply to:

Draft