Unable to get full url to page with Dynamic Module Content

Posted by Community Admin on 04-Aug-2018 22:42

Unable to get full url to page with Dynamic Module Content

All Replies

Posted by Community Admin on 05-Nov-2013 00:00

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 problem I have is that no matter which way I come at building the URL I cannot get the full url to the page.
Instead of
domain.com/.../programmer-developer
I get
domain.com/programmer-developer

I've even tried hacking around it and using the page segment to rebuild the URL and in the sent email it always strips out the URL segment "current-positions".

Am I missing something?

Regards,

Jason

Posted by Community Admin on 08-Nov-2013 00:00

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.

Posted by Community Admin on 08-Nov-2013 00:00

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 page
if (!temp.SystemUrl.Contains(WebConfigurationManager.AppSettings["CareerListingPage"]))
 temp.SystemUrl = WebConfigurationManager.AppSettings["CareerListingPage"] + temp.SystemUrl;

I've moved the variable out into an appsetting in case the location of the listing page ever changes and I'll at least have a quick way to update it.

Cheers,
Jason

Posted by Community Admin on 02-Oct-2014 00:00

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()

This thread is closed