Hi guys,
I'm trying to build a custom sitemap but having some difficulties.
The sitemap used to work, but now I have pages that require a user to be logged-in first.
If I use the SiteMap.RootNode and the loop through all the children I dont see the "protected" pages.
So then I used the CmsManager.GetPages() which returns all the pages and thats all good, BUT I need the sitemap to display as it displays in the CMS, in that order.
Now it seems like the "Ordinal" value only applies for a group and the pages in the group or something, I have found a thread where it will sort the pages with the ordinal but the menu is still messed-up and not in the order as it is in the cms.
Can anyone help me on how to sort the items so that they will display as in the admin area?
Here is the code I'm using but does not seem to do exactly what I want( I have just added some custom code that will check if a user may see the page, and only then add it to the List ) :
I'm trying to build a custom sitemap but having some difficulties.
The sitemap used to work, but now I have pages that require a user to be logged-in first.
If I use the SiteMap.RootNode and the loop through all the children I dont see the "protected" pages.
So then I used the CmsManager.GetPages() which returns all the pages and thats all good, BUT I need the sitemap to display as it displays in the CMS, in that order.
Now it seems like the "Ordinal" value only applies for a group and the pages in the group or something, I have found a thread where it will sort the pages with the ordinal but the menu is still messed-up and not in the order as it is in the cms.
Can anyone help me on how to sort the items so that they will display as in the admin area?
Here is the code I'm using but does not seem to do exactly what I want( I have just added some custom code that will check if a user may see the page, and only then add it to the List ) :
internal
class
CmsPageComarer : IComparer<ICmsPage>
{
#region IComparer<ICmsPage> Members
public
int
Compare( ICmsPage x, ICmsPage y )
{
return
x.Ordinal.CompareTo( y.Ordinal );
}
#endregion
}
private
List<ICmsPage> GetSource()
{
CmsManager manager =
new
CmsManager();
IList pages = manager.GetPages();
List<ICmsPage> source =
new
List<ICmsPage>();
foreach
( ICmsPage page
in
pages )
{
string
lang =
"en"
;
if
( Request.Url.ToString().ToLower().Contains(
"/af/"
) ) lang =
"af"
;
int
langCode = 0;
if
( lang.Equals(
"en"
) ) langCode = 127;
if
( lang.Equals(
"af"
) ) langCode = 54;
if
( IsPageVisibleToUser( page ) && page.Navigable && page.LangID == langCode )
{
//show in menu
source.Add( page );
}
}
CmsPageComarer comparer =
new
CmsPageComarer();
source.Sort( comparer );
return
source;
}