Unable to get full url to page with Dynamic Module Content
Here's the situation. I have a simple module called "Jobs" with a
content type "Current Openings". Within the site there is a listing page
at domain.com/.../ that lists all current job openings. The titles of the listings link to the detail page for each such as domain.com/.../.
I am building an alert service that automates sending daily alerts to subscribers with an email containing any new openings. This setup uses the Campaign, Subscribers, MessageBody and creates a new campaign issue for distribution and sends it through.
My problem is simple, I am creating the email MessageBody dynamically using the records I want.
var recentCareers = CurrentOpenings().Where(b => b.GetValue<bool>("Alerted")).OrderByDescending(x => x.GetValue<DateTime?>("PublishDate")); if (recentCareers.Count() > 0) recentOpenings = "<h2>Recent Openings</h2>";foreach (var opening in recentCareers) if (opening.Status == ContentLifecycleStatus.Live) recentOpenings += "<h3><a href=\"" + opening.SystemUrl + "\">" + opening.GetValue("Title") + "</a></h3>"; recentOpenings += opening.GetValue("Summary"); The code is actually returning the correct value. The thing about it that it doesn't know which page your widget is on to display only it's own url which is "programmer-developer" you will need to build the url yourself.
I get that the underlying value is correct and that the piece that is missing is the context with where the page widget is. The problem I have is that building the URL myself has failed in that the generated campaign email that goes out seems to be rebuilding the link and stripping out even my hard-coded url segment.
I have found another way around this by temporarily resetting the SystemUrl of the record, building the distribution dynamically, sending the email and simply not saving the changes back to the record.
// Workaround to temporarily add the parent URL segment for the details pageif (!temp.SystemUrl.Contains(WebConfigurationManager.AppSettings["CareerListingPage"])) temp.SystemUrl = WebConfigurationManager.AppSettings["CareerListingPage"] + temp.SystemUrl;you can write this in teh widget html to get the current page the widget laid in
new PageManager().GetPageNode(
new Guid(Telerik.Sitefinity.Web.SiteMapBase.GetCurrentProvider().CurrentNode.Key)
).GetFullUrl()