Copied to clipboard

Flag this post as spam?

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


  • Katlynn 18 posts 89 karma points
    Mar 06, 2019 @ 16:37
    Katlynn
    0

    RSS Macro and XSLT Broken

    Hi there! We inherited a site on the Umbraco framework from a developer that is no longer in business.

    They had previously created a custom RSS macro that styled our event feed pulled in from an off-site source. Recently, however, that functionality broke, and I've been struggling to figure out why ever since.

    We patched together a workaround and used a different RSS generator, but we'd really like to know what went wrong with this one.

    As far as the macro is concerned, all I can find that is related to the event callback is below. The RSS url is pulled in via a field on our top-level site identity, https://www.alumnionline.pitt.edu/controls/cmsv2/components/rss/rss.aspx?sid=1729&gid=2&calcid=1419&pageid=637.

    The RSS feed is functioning just fine and works well with other generators or scripts, so that leads me to believe there's something wonky going on with the code below. Any ideas are appreciated! Thanks!

    <xsl:output method="xml" omit-xml-declaration="yes" indent="yes" />
    
    <xsl:param name="currentPage"/>
    <xsl:variable name="imdodurl" select="$currentPage/ancestor-or-self::*[@isDoc]/iModulesRSSUrl" />
    <xsl:variable name="type" select="/macro/listType" />
    <xsl:variable name="feed" select="umbraco.library:GetXmlDocumentByUrl($imdodurl)" />
    <xsl:variable name="category">
        <xsl:choose>
            <xsl:when test="string-length(umbraco.library:RequestQueryString('category')) &gt; 0">
                <xsl:value-of select="umbraco.library:RequestQueryString('category')"/>
            </xsl:when>
            <xsl:otherwise>all</xsl:otherwise>
        </xsl:choose>
    </xsl:variable> 
    <xsl:variable name="month">
        <xsl:choose>
            <xsl:when test="string-length(umbraco.library:RequestQueryString('month')) &gt; 0">
                <xsl:value-of select="umbraco.library:RequestQueryString('month')"/>
            </xsl:when>
            <xsl:otherwise>all</xsl:otherwise>
        </xsl:choose>
    </xsl:variable> 
    
    <xsl:variable name="allcatstring">
        <xsl:for-each select="$feed/rss/channel/item">
            <xsl:variable name="catstring" select='substring-before(substring-after(description, "Type:&#60;/b&#62;"), "&#60;br/&#62;&#60;b&#62;Description")'/>
            <xsl:value-of select="$catstring" />,
        </xsl:for-each>
    </xsl:variable>
    <xsl:variable name="splitCats" select="umbraco.library:Split($allcatstring, ',')" />
    <xsl:variable name="uniqueCategories"  select="$splitCats/value [not(.=following::value)]" />
    
    <xsl:template match="/">
    
        <xsl:choose>
            <xsl:when test="$type = 'homepage'">
                <xsl:call-template name="homepage" />
            </xsl:when>
            <xsl:when test="$type = 'byclub'">
                <xsl:variable name="pageTitle" select="$currentPage/@nodeName" />
                <xsl:if test="count($feed/rss/channel/item [contains(title, $pageTitle)]) &gt; 0">
                    <xsl:call-template name="byclub" />
                </xsl:if>
            </xsl:when>
            <xsl:when test="$type = 'topthree'">
                <xsl:call-template name="topthree" />
            </xsl:when>
            <xsl:when test="$type = 'topthreeblocks'">
                <xsl:call-template name="topthreeblocks" />
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="fulllist" />
            </xsl:otherwise>
    
        </xsl:choose>
    </xsl:template>
    
    <xsl:template name="topthree">
        <div class="row">
            <div class="small-12 columns">
                <h4>Upcoming Events</h4>
            </div>
            <hr />
            <xsl:for-each select="$feed/rss/channel/item">  
                <xsl:if test="position() &lt; 4">
                <xsl:variable name="desc" select="description" />
                <xsl:variable name="datestring" select='substring-after($desc, "Date:&#60;/span&#62;")'/>
                <div class="small-12 columns">
                    <h2><xsl:value-of select="title" disable-output-escaping="yes" /></h2>
                    <h3><xsl:value-of select="$datestring" /></h3>
                    <p class="byline"><xsl:value-of select="substring-after($desc, 'Description:&lt;/b&gt;')" disable-output-escaping="yes"/></p>
                </div>
                </xsl:if>
            </xsl:for-each>
        </div>
    </xsl:template>
    
    <xsl:template name="topthreeblocks">
        <div class="row">
            <div class="small-12 columns">
                <h4>Events</h4>
            </div>
            <div class="row">
            <xsl:for-each select="$feed/rss/channel/item">
                <xsl:if test="position() &lt; 4">
                    <xsl:variable name="desc" select="description" />
                    <xsl:variable name="datestring" select='substring-after($desc, "Date:&#60;/span&#62;")'/>
    
                        <div class="medium-4 columns">
                            <div class="event-block">
                                <div class="event-block-stripe top">&nbsp;</div>
                                <span class="event-block-date"><xsl:value-of select="$datestring" /></span>
                                <h2><xsl:value-of select="title" disable-output-escaping="yes" /></h2>
                                <a class="event-block-get-info" target="_blank" href="{link}">Get Info</a>
                                <div class="event-block-stripe bottom">&nbsp;</div>
                            </div>
                        </div>
                </xsl:if>
            </xsl:for-each>
            </div>
        </div>
    </xsl:template>
    
    <xsl:template name="homepage">
        <div class="homepage-events">
            <h4 class="section-title">Events</h4>
            <span class="see-all"><a href="/news-events/events-calendar/">See all events</a></span>
            <xsl:for-each select="$feed/rss/channel/item">
                <xsl:if test="position() &lt;= 5">
                    <xsl:variable name="desc" select="description" />
                        <div class="row event-post">
                            <xsl:variable name="datestring" select='substring-after($desc, "Date:&#60;/span&#62;")'/>
    
                            <xsl:variable name="datesplit" select="umbraco.library:Split($datestring, '/')"/>
    
                            <div class="large-2 small-2 columns event-date">
    
    
    
                                <xsl:choose>
                            <xsl:when test="$datesplit/value[1] = 1">
                                Jan
                            </xsl:when>
                            <xsl:when test="$datesplit/value[1] = 2">
                                Feb
                            </xsl:when>
                            <xsl:when test="$datesplit/value[1] = 3">
                                Mar
                            </xsl:when>
                            <xsl:when test="$datesplit/value[1] = 4">
                                Apr
                            </xsl:when>
                            <xsl:when test="$datesplit/value[1] = 5">
                                May
                            </xsl:when>
                            <xsl:when test="$datesplit/value[1] = 6">
                                June
                            </xsl:when>
                            <xsl:when test="$datesplit/value[1] = 7">
                                July
                            </xsl:when>
                            <xsl:when test="$datesplit/value[1] = 8">
                                Aug
                            </xsl:when>
                            <xsl:when test="$datesplit/value[1] = 9">
                                Sept
                            </xsl:when>
                            <xsl:when test="$datesplit/value[1] = 10">
                                Oct
                            </xsl:when>
                            <xsl:when test="$datesplit/value[1] = 11">
                                Nov
                            </xsl:when>
                            <xsl:when test="$datesplit/value[1] = 12">
                                Dec
                            </xsl:when>
                            <xsl:otherwise>
                                Error
                            </xsl:otherwise>
                        </xsl:choose>
    
    
    
    
                                     <span><xsl:value-of select="$datesplit/value[2]" /></span>
    
    
    
                            </div>
                            <div class="large-10 small-10 columns event-content">
                                <h5><a target="_blank" href="{link}"><xsl:value-of select="title" disable-output-escaping="yes" /></a></h5>
                                <a target="_blank" class="event-get-info" href="{link}">GET INFO</a>
                            </div>
                        </div>
                    </xsl:if>
                </xsl:for-each>
            </div>
        </xsl:template>
    
        <xsl:template name="byclub">
            <xsl:variable name="pageTitle" select="$currentPage/@nodeName" />
            <div class="row">
                <div class="small-12 columns">
                    <h4>Local Events</h4>
                </div>
                <xsl:for-each select="$feed/rss/channel/item [contains(title, $pageTitle)]">    
                    <xsl:variable name="desc" select="description" />
                    <xsl:variable name="datestring" select='substring-before(substring-after($desc, "&lt;b&gt;Start&amp;nbsp;Date:&lt;/b&gt;"), "&lt;br/&gt;&lt;b&gt;End")'/>
                    <div class="small-12 columns">
                        <h2><xsl:value-of select="title" /></h2>
                        <h3><xsl:value-of select="$datestring" /></h3>
                        <p class="byline"><xsl:value-of select="substring-after($desc, 'Description:&lt;/b&gt;')" disable-output-escaping="yes"/></p>
                    </div>
                </xsl:for-each>
            </div>
        </xsl:template>
    
        <xsl:template name="genericlist">
        </xsl:template>
    
        <xsl:template name="fulllist">
    
    
            <hr />
    
            <div id="events-calendar" class="row">
                <xsl:choose>
                    <xsl:when test="$category != 'all' and $month = 'all' and count($feed/rss/channel/item [contains(ucomponents.strings:StripWhitespace(description), $category)]) &gt; 0">
                        <xsl:for-each select="$feed/rss/channel/item [contains(ucomponents.strings:StripWhitespace(description), $category)]">
                            <xsl:call-template name="sortedMarkup" />
                        </xsl:for-each>
                    </xsl:when>
    
                    <xsl:when test="$category != 'all' and $month != 'all' and count($feed/rss/channel/item [contains(ucomponents.strings:StripWhitespace(description), $category) and contains(ucomponents.strings:StripWhitespace(description), $month)]) &gt; 0">
                        <xsl:for-each select="$feed/rss/channel/item [contains(ucomponents.strings:StripWhitespace(description), $category) and contains(ucomponents.strings:StripWhitespace(description), $month)]">
                            <xsl:call-template name="sortedMarkup" />
                        </xsl:for-each>
                    </xsl:when>
    
                    <xsl:when test="$category = 'all' and $month != 'all' and count($feed/rss/channel/item [contains(ucomponents.strings:StripWhitespace(description), $month)]) &gt; 0">
                        <xsl:for-each select="$feed/rss/channel/item [contains(ucomponents.strings:StripWhitespace(description), $month)]">
                            <xsl:call-template name="sortedMarkup" />
                        </xsl:for-each>
                    </xsl:when>
    
                    <xsl:when test="$category = 'all' and $month = 'all' and count($feed/rss/channel/item) &gt; 0">
                        <xsl:for-each select="$feed/rss/channel/item">
                            <xsl:call-template name="sortedMarkup" />
                        </xsl:for-each>
                    </xsl:when>
    
                    <xsl:otherwise>
                        <h2>There are currently no events</h2>
                    </xsl:otherwise>
                </xsl:choose>
            </div>
        </xsl:template>
    
        <xsl:template name="sortedMarkup">
            <xsl:variable name="desc" select="description" />
            <xsl:variable name="catstring" select='substring-before(substring-after(description, "Type:&#60;/b&#62;"), "&#60;br/&#62;&#60;b&#62;Description")'/>
            <xsl:variable name="datestring" select='substring-after($desc, "Date:&#60;/span&#62;")'/>
    
            <xsl:variable name="datesplit" select="umbraco.library:Split($datestring, '/')"/>
    
            <xsl:variable name="cleansed" select="ucomponents.strings:StripWhitespace($catstring)" />
            <xsl:variable name="splitYear" select="substring($datesplit/value[3], 1, 4)" />
    
    
    
    
            <div class="event clearfix">
                <!--This can have date inside Cal icon -->
                <div class ="calendar large-2 small-3 columns">
                    <a href="{link}">
                        <span class="fa-stack fa-1x">
                            <i class="fa fa-calendar-o fa-stack-2x">&nbsp;</i>          
                            <strong class="fa-stack-1x calendar-text"><xsl:value-of select="$datesplit/value[2]" /></strong>
    
    
                        </span>
                    </a>
                </div>
                <div class="large-10 small-9 columns" data-categories="{translate($cleansed, ',',' ')}">
    
                    <h6>
                        <xsl:choose>
                            <xsl:when test="$datesplit/value[1] = 1">
                                January
                            </xsl:when>
                            <xsl:when test="$datesplit/value[1] = 2">
                                February
                            </xsl:when>
                            <xsl:when test="$datesplit/value[1] = 3">
                                March
                            </xsl:when>
                            <xsl:when test="$datesplit/value[1] = 4">
                                April
                            </xsl:when>
                            <xsl:when test="$datesplit/value[1] = 5">
                                May
                            </xsl:when>
                            <xsl:when test="$datesplit/value[1] = 6">
                                June
                            </xsl:when>
                            <xsl:when test="$datesplit/value[1] = 7">
                                July
                            </xsl:when>
                            <xsl:when test="$datesplit/value[1] = 8">
                                August
                            </xsl:when>
                            <xsl:when test="$datesplit/value[1] = 9">
                                September
                            </xsl:when>
                            <xsl:when test="$datesplit/value[1] = 10">
                                October
                            </xsl:when>
                            <xsl:when test="$datesplit/value[1] = 11">
                                November
                            </xsl:when>
                            <xsl:when test="$datesplit/value[1] = 12">
                                December
                            </xsl:when>
                            <xsl:otherwise>
                                Error
                            </xsl:otherwise>
                        </xsl:choose>
                        <xsl:value-of select="$datesplit/value[2]"/>, <xsl:value-of select="$splitYear"/>
                    </h6>
                    <a href="{link}"><xsl:value-of select="title" disable-output-escaping="yes" /></a>
                    <p><xsl:value-of select="substring-after($datestring, $splitYear)" disable-output-escaping="yes" /></p>
    
                </div>
            </div>
        </xsl:template>
    

  • Alex Skrypnyk 6150 posts 24110 karma points MVP 8x admin c-trib
    Aug 29, 2019 @ 22:33
    Alex Skrypnyk
    0

    Hi Katlyn

    Did you solve this issue?

Please Sign in or register to post replies

Write your reply to:

Draft