+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Unable to get full url to page with Dynamic Module Content

Unable to get full url to page with Dynamic Module Content

4 posts, 0 answered
  1. Jason Rayner
    Jason Rayner avatar
    9 posts
    Registered:
    13 Apr 2005
    05 Nov 2013
    Link to this post
    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 http://domain.com/current-positions/ that lists all current job openings. The titles of the listings link to the detail page for each such as http://domain.com/current-positions/programmer-developer/.

    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
    http://domain.com/current-positions/programmer-developer
    I get
    http://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
  2. Jonathan
    Jonathan avatar
    119 posts
    Registered:
    19 Dec 2012
    08 Nov 2013 in reply to Jason Rayner
    Link to this post
    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.
  3. Jason Rayner
    Jason Rayner avatar
    9 posts
    Registered:
    13 Apr 2005
    08 Nov 2013 in reply to Jonathan
    Link to this post
    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
  4. Bishoy
    Bishoy avatar
    27 posts
    Registered:
    15 Aug 2013
    02 Oct 2014
    Link to this post

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

4 posts, 0 answered