I am rendering custom menu items in the application started event. I am not entirely happy with the speed they load. There is a bit of a lag when right clicking on the nodes or clicking on the action buttons.
I just wondered if there was some way I can hard code these. Possibly in config files so they load faster.
private void ContentTreeController_MenuRendering(TreeControllerBase sender, MenuRenderingEventArgs e)
{
var treeAlias = sender.TreeAlias;
var queryString = e.QueryStrings["id"];
if (e.NodeId != "-1")
{
var contentService = ApplicationContext.Current.Services.ContentService;
int nodeId;
if (int.TryParse(e.NodeId, out nodeId))
{
var content = contentService.GetById(nodeId);
if (content != null)
{
var nodeTypeAlias = content.ContentType.Alias;
if (nodeTypeAlias == "emailAlertsFolder")
{
var sendJobAlerts = new MenuItem("sendJobAlerts", "Send Job Alerts");
sendJobAlerts.AdditionalData.Add("actionView", "/App_Plugins/BackendExtensions/views/SendJobAlerts.html");
sendJobAlerts.Icon = "right-double-arrow color-red";
e.Menu.Items.Insert(e.Menu.Items.Count, sendJobAlerts);
var sendHotCandidateAlerts = new MenuItem("sendHotCandidateAlerts", "Send Hot Candidate Alerts");
sendHotCandidateAlerts.AdditionalData.Add("actionView", "/App_Plugins/BackendExtensions/views/SendHotCandidateAlerts.html");
sendHotCandidateAlerts.Icon = "right-double-arrow color-red";
e.Menu.Items.Insert(e.Menu.Items.Count, sendHotCandidateAlerts);
var sendBlogAlerts = new MenuItem("sendBlogAlerts", "Send Blog Alerts");
sendBlogAlerts.AdditionalData.Add("actionView", "/App_Plugins/BackendExtensions/views/SendBlogAlerts.html");
sendBlogAlerts.Icon = "right-double-arrow color-red";
e.Menu.Items.Insert(e.Menu.Items.Count, sendBlogAlerts);
}
if (nodeTypeAlias == "jobsListFolder")
{
var archiveExpiredJobs = new MenuItem("archiveExpiredJobs", "Archive Expired Jobs");
archiveExpiredJobs.AdditionalData.Add("actionView", "/App_Plugins/BackendExtensions/views/ArchiveExpiredJobs.html");
archiveExpiredJobs.Icon = "re-post color-red";
e.Menu.Items.Insert(e.Menu.Items.Count, archiveExpiredJobs);
};
}
}
}
}
If anyone could tell me how the replicate the following in config that would be awesome.
Umbraco Hardcoded Tree Context Menu Items
Hi Guys,
I am rendering custom menu items in the application started event. I am not entirely happy with the speed they load. There is a bit of a lag when right clicking on the nodes or clicking on the action buttons.
I just wondered if there was some way I can hard code these. Possibly in config files so they load faster.
If anyone could tell me how the replicate the following in config that would be awesome.
Kind Regards
David
Hi,
I optimized the code slightly. Not sure what was going on there. Must have copied and pasted from some old code :(
Anyway this seems to work faster. No need to mess around with the contentService. Simply checking the hard coded Id is sufficient in this case.
I would be still interested in hearing if anyone knows how to hardcode a context menu tree structure.
Kind Regards
David
is working on a reply...