Okay, so this problem has been driving me nuts for a while now. I'm working for a client who has a site on Umbraco, they're a recruitment company and they're using a database from First Choice (The Access Group). I'd never used C# before but I've learned a lot from just making fixes to the site. The one main issue I'm having is that they want an RSS Feed for their jobs so they can be posted out to social media, however, the Jobs are all posted from their database through a macro which is technically 'empty' when viewed but is populated by the macro.
I've created several flavours of RSS (Even resorted to an Umbraco plugin that didn't help), I've gone onto the server and made sure I'm using the correct syntax, naming conventions and titles for the jobs but still nothing works.
Now, I'm nearly 100% sure I'm just being stupid, but I'm stumped. Any help would be really appreciated.
Here's the code I've got so far for the feed:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
Layout = null;
Response.AddHeader("Content-Type", "text/xml");
const string DATE_FORMAT = "ddd, dd MMM yyyy hh:mm:ss zzz";
const string FEED_TITLE = "Millar Cameron Jobs";
const string FEED_DESCRIPTION = "Millar Cameron Jobs | Exciting job opportunites across the globe";
const string CREATOR_NAME = "tPegler";
const string CATEGORY = "Recruitment";
const string UPDATE_PERIOD = "daily";
const int UPDATE_FREQUENCY = 1;
const string LANGUAGE = "en-US";
const string HOME_PAGE_DOC_TYPE_ALIAS = "Home";
const string FEED_PARENT_DOC_TYPE_ALIAS = "TextPage";
const string ARTICLE_DOC_TYPE_ALIAS = "TextPage";
const string ARTICLE_TITLE_PROPERTY_ALIAS = "vm.JobDetails.Title";
const string ARTICLE_DATE_PROPERTY_ALIAS = "vm.JobDetails.Date";
const string ARTICLE_REFERENCE_ALIAS = "vm.JobDetails.JobRefNo";
const string ARTICLE_TERM_ALIAS = "vm.JobDetails.Term";
const string ARTICLE_LOCATION_ALIAS = "vm.JobDetails.Location";
const string ARTICLE_DESCRIPTION_ALIAS = "vm.JobDetails.Description";
const int CONTENT_PREVIEW_LENGTH = 500;
IPublishedContent homePage = Model.Content.AncestorOrSelf(1).DescendantsOrSelf().Where(x => x.DocumentTypeAlias == HOME_PAGE_DOC_TYPE_ALIAS).FirstOrDefault();
IPublishedContent feedParentPage = homePage.Descendants().Where(x => x.DocumentTypeAlias == FEED_PARENT_DOC_TYPE_ALIAS).FirstOrDefault();
IEnumerable<IPublishedContent> feedItems = feedParentPage.Descendants().Where(x => x.DocumentTypeAlias == ARTICLE_DOC_TYPE_ALIAS && x.IsVisible()).OrderByDescending(x => (DateTime)x.GetPropertyValue(ARTICLE_DATE_PROPERTY_ALIAS));
string siteUrl = homePage.UrlWithDomain();
string feedUrl = ((IPublishedContent)CurrentPage).UrlWithDomain();
}
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/">
<channel>
<title>@FEED_TITLE</title>
<atom:link href="http://www.millarcameron.com/jobs" rel="self" type="application/rss+xml" />
<link>http://www.millarcameron.com/jobs</link>
<description>@FEED_DESCRIPTION</description>
<language>@LANGUAGE</language>
<sy:updatePeriod>@UPDATE_PERIOD</sy:updatePeriod>
<sy:updateFrequency>@UPDATE_FREQUENCY</sy:updateFrequency>
@foreach (IPublishedContent item in feedItems.OrderBy(ARTICLE_DATE_PROPERTY_ALIAS + " desc"))
{
string articleDescription = Umbraco.Truncate(umbraco.library.StripHtml(item.GetGridHtml("contentGrid", "bootstrap3").ToString()), CONTENT_PREVIEW_LENGTH).ToString().Replace("…", "...");
@:<item>
<title>@(item.HasProperty(ARTICLE_TITLE_PROPERTY_ALIAS) ? item.GetPropertyValue<string>(ARTICLE_TITLE_PROPERTY_ALIAS) : item.Name)</title>
@:<link>
@umbraco.library.NiceUrlWithDomain(item.Id)
@:</link>
<dc:creator><![CDATA[@CREATOR_NAME]]></dc:creator>
<category><![CDATA[@CATEGORY]]></category>
<guid isPermaLink="false">@item.UrlWithDomain()</guid>
<description><![CDATA[@ARTICLE_LOCATION_ALIAS]]><![CDATA[@ARTICLE_TERM_ALIAS]]><![CDATA[@ARTICLE_DESCRIPTION_ALIAS]]></description>
@:</item>
}
</channel>
Everything displays fine except the actual items. They're not found at all.
EDIT//**
So, I've still had no luck with this at all and I've tried everything I can think of. Here's the code you get when viewing source of the job board:
<div class='jobpage'>
<div ng-include="'/scripts/websuite/views/SearchResultsCtrl.html'"></div>
<div ng-controller="latestJobsSettingsCtrl" ng-init="vm.setProperties('','10')">
<div ng-include="'/scripts/websuite/views/LatestJobsCtrl.html'"></div>
</div>
And here is the code from each individual job posting.:
<div class='container'>
<div class="row clearfix">
<div class="col-lg-4 column">
<div class='jobpage'>
<div ng-include="'/scripts/websuite/views/SearchFiltersCtrl.html'"></div>
</div>
</div> <div class="col-lg-8 column">
<div class='jobpage'>
<div ng-include="'/scripts/websuite/views/JobDetailsCtrl.html'"></div>
<div ng-include="'/scripts/websuite/views/ApplyForJobCtrl.html'"></div>
That's it. If I inspect the pages, everything is there but in source it isn't. I know it's difficult to pull dynamically created content to an RSS feed because it isn't actually 'there' but there must be some way.
Do you have more than one TextPage type page underneath the home page? Unless the one with the feed items in is the very first one in the list, you'll just get one of the other pages instead.
Easiest way to test this is to put the id of the feed parent page in the RSS title or something, and see if it's pulling out the right ID (you can check in the back office to get the ID of the parent page you want). If they're not the same ID, that'll be the problem.
I notice that both the parent page and the article pages are of type TextPage, usually you'd have a separate DocType for both to make targeting and querying them easier.