4.2 BlogPost URL Problems

Posted by Community Admin on 04-Aug-2018 21:31

4.2 BlogPost URL Problems

All Replies

Posted by Community Admin on 03-Oct-2011 00:00

Hello, I am currently in the process of migrating a Sitefinity 3.7 project to 4.2, and have run into an issue while rewriting parts of a widget.

In short, it gets the last X comments for blog posts. That part I have squared away just fine, but I am having problems trying to link to the blog post.

If I am to do:
 
blogPost.Parent.Urls.Where(x => x.RedirectToDefault == false).First().Url + blogPost.Urls.Where(x => x.RedirectToDefault == false).First().Url

I get /Back_to_School_Tips/10-07-30/Back_to_School_Tips.aspx

What I am EXPECTING back is /multimedia/forums/Back_to_School_Tips/10-07-30/Back_to_School_Tips.aspx

Because the "back to school tips" blog is under the forums page which is a child of the multimedia page.

Is there something simple I'm just not getting? I've spent most of today searching for an answer to this problem. It seems silly that there wouldn't be an easy way for me to get back the entire URL.

Posted by Community Admin on 05-Oct-2011 00:00

Hi dustin,

Have you already set a default page in the parent blog settings? If so, you can retrieve this property using the property: DefaultPageId

something like this should work

var blogPageId = blog.DefaultPageId;
var landingPage = App.WorkWith().Pages().Where(p => p.Id == blogPageId).Get().Single();
var blogUrl = landingPage.GetFullUrl();

be sure to include the namespace Telerik.Sitefinity.Module.Pages to be able to use the GetFullUrl extension method.

hope this is helpful!

This thread is closed