Correct arguments for a custom MegaMenu navigation
I am working on a custom MegaMenu for my website navigation but I don't think I am using correct arguments.
As you know, Sitefinity pages can have five different statuses:
1) Published and Show in Navigation
2) Published but don't show in Navigation
3) Unpublished
4) Use this page only to group other pages
5) Use this page to redirect to another page
With the code below, I have managed to take care of the status list above for my pages. (I don't want unpublished pages and those that are set to "Not to show in navigation" and those pages that are used only to group other pages to show up in my dropdown menu).
So far everything looks good but I get an error when I use one of those hidden pages (those that are set "Not to show in navigation") to display the content of my single item widgets. For example, when I am using the "News" widget, if I choose "Selected existing page.." for displaying my single item detail page, and if the selected page is set not to show in navigation, then I get an error.
What are the correct arguments to use for my menu? I think my problem with this custom menu will be fixed if I use Radmenu's arguments, because when I choose not to use the custom MegaMenu, then Radmenu doesn't give me that error.
This is the code I am using and I am using Sitefinity 6.0:
void
MegaMenuTemplate_IsNodeAccessible(
object
sender, IsAccessibleArgs e)
var pageNode = e.Node
as
PageSiteNode;
if
(pageNode !=
null
)
if
((String.IsNullOrEmpty(pageNode.Title) &&
// used in multilingual; captures the cases of synced, split, and group pages
pageNode.Id != SiteInitializer.CurrentFrontendRootNodeId))
// ensures that the root node is not hidden and thus all other pages
e.IsAccessible =
false
;
return
;
//The page should be hidden if it is a group page and it has no child pages.
if
(pageNode.IsGroupPage && pageNode.ChildNodes.Count < 1)
e.IsAccessible =
false
;
return
;
//Added for preventing the unpublished pages to show in navigation
if
(pageNode.ShowInNavigation ==
false
)
e.IsAccessible =
false
;
return
;
if
(pageNode.Title !=
"Pages"
&& pageNode.Status != Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live)
e.IsAccessible =
false
;
return
;
else
throw
new
NotSupportedException(
"The supported types are 'TaxonSiteNode' or 'PageSiteNode'."
);
e.IsAccessible =
true
;
Hello Faramarz,
I have already responded to you in the support ticket. Please try the control and let me know if it works for you! :)
Regards,Jen, I really appreciate it. It works :)