19 Aug 2009
15 Mar 2010
Link to this post
I was trying to use UrlHelper.GetUrl(string, bool) to get the URL of a page group, ultimately to get the ID of the page group and programmatically add a page under it. I was using a value for "url" of "/subdomain/pagegroupname". When I did this, and there were no existing pages in the page group, GetUrl returned null. Out of curiosity, I added a page to the page group manually, through the dashboard. Then, when I ran my code again, I had no problem.
So, it looks like GetUrl will only get the URL of a page group if it contains pages. Is this the case, and if so, is this by design? Fortunately, we will have some default pages in this particular page group before the user will be using the page I'm developing, so we won't have this problem. However, it seems reasonable to want to be able to programmatically add pages to an empty page group.
Am I missing something here?